0s autopkgtest [17:23:40]: starting date and time: 2025-05-06 17:23:40+0000 0s autopkgtest [17:23:40]: git checkout: 9986aa8c Merge branch 'skia/fix_network_interface' into 'ubuntu/production' 0s autopkgtest [17:23:40]: host juju-7f2275-prod-proposed-migration-environment-2; command line: /home/ubuntu/autopkgtest/runner/autopkgtest --output-dir /tmp/autopkgtest-work.ohxeww6a/out --timeout-copy=6000 --setup-commands /home/ubuntu/autopkgtest-cloud/worker-config-production/setup-canonical.sh --apt-pocket=proposed=src:python-xarray,src:matplotlib --apt-upgrade pandas --timeout-short=300 --timeout-copy=20000 --timeout-test=20000 --timeout-build=20000 '--env=ADT_TEST_TRIGGERS=python-xarray/2025.03.1-8 matplotlib/3.10.1+dfsg1-3' -- ssh -s /home/ubuntu/autopkgtest/ssh-setup/nova -- --flavor autopkgtest-big-s390x --security-groups autopkgtest-juju-7f2275-prod-proposed-migration-environment-2@bos03-s390x-4.secgroup --name adt-questing-s390x-pandas-20250506-172340-juju-7f2275-prod-proposed-migration-environment-2-c8a79876-2c77-4977-a1c6-4944993fc9f9 --image adt/ubuntu-questing-s390x-server --keyname testbed-juju-7f2275-prod-proposed-migration-environment-2 --net-id=net_prod-proposed-migration-s390x -e TERM=linux --mirror=http://ftpmaster.internal/ubuntu/ 85s autopkgtest [17:25:05]: testbed dpkg architecture: s390x 86s autopkgtest [17:25:06]: testbed apt version: 3.0.0 86s autopkgtest [17:25:06]: @@@@@@@@@@@@@@@@@@@@ test bed setup 86s autopkgtest [17:25:06]: testbed release detected to be: None 87s autopkgtest [17:25:07]: updating testbed package index (apt update) 87s Get:1 http://ftpmaster.internal/ubuntu questing-proposed InRelease [110 kB] 87s Hit:2 http://ftpmaster.internal/ubuntu questing InRelease 87s Hit:3 http://ftpmaster.internal/ubuntu questing-updates InRelease 87s Hit:4 http://ftpmaster.internal/ubuntu questing-security InRelease 87s Get:5 http://ftpmaster.internal/ubuntu questing-proposed/universe Sources [580 kB] 88s Get:6 http://ftpmaster.internal/ubuntu questing-proposed/main Sources [67.8 kB] 88s Get:7 http://ftpmaster.internal/ubuntu questing-proposed/multiverse Sources [27.3 kB] 88s Get:8 http://ftpmaster.internal/ubuntu questing-proposed/main s390x Packages [129 kB] 88s Get:9 http://ftpmaster.internal/ubuntu questing-proposed/universe s390x Packages [604 kB] 88s Get:10 http://ftpmaster.internal/ubuntu questing-proposed/multiverse s390x Packages [15.0 kB] 88s Fetched 1533 kB in 1s (1719 kB/s) 88s Reading package lists... 89s autopkgtest [17:25:09]: upgrading testbed (apt dist-upgrade and autopurge) 89s Reading package lists... 89s Building dependency tree... 89s Reading state information... 89s Calculating upgrade...Starting pkgProblemResolver with broken count: 0 89s Starting 2 pkgProblemResolver with broken count: 0 89s Done 90s Entering ResolveByKeep 90s 90s Calculating upgrade... 90s The following packages will be upgraded: 90s dhcpcd-base dirmngr gcc-15-base gir1.2-glib-2.0 gnupg gnupg-l10n gnupg-utils 90s gpg gpg-agent gpg-wks-client gpgconf gpgsm gpgv keyboxd libatomic1 90s libdebuginfod-common libdebuginfod1t64 libdw1t64 libelf1t64 libgcc-s1 90s libglib2.0-0t64 libglib2.0-data libnuma1 libperl5.40 libpython3.12-minimal 90s libpython3.12-stdlib libpython3.12t64 libsemanage-common libsemanage2 90s libstdc++6 libx11-6 libx11-data libxml2 lto-disabled-list numactl 90s openssh-client openssh-server openssh-sftp-server perl perl-base 90s perl-modules-5.40 python3-dbus python3-wadllib sensible-utils 90s 44 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 90s Need to get 25.1 MB of archives. 90s After this operation, 218 kB disk space will be freed. 90s Get:1 http://ftpmaster.internal/ubuntu questing/main s390x libperl5.40 s390x 5.40.1-3 [4972 kB] 91s Get:2 http://ftpmaster.internal/ubuntu questing/main s390x perl s390x 5.40.1-3 [262 kB] 91s Get:3 http://ftpmaster.internal/ubuntu questing/main s390x perl-base s390x 5.40.1-3 [1954 kB] 92s Get:4 http://ftpmaster.internal/ubuntu questing/main s390x perl-modules-5.40 all 5.40.1-3 [3217 kB] 92s Get:5 http://ftpmaster.internal/ubuntu questing/main s390x libdebuginfod-common all 0.193-1 [15.6 kB] 92s Get:6 http://ftpmaster.internal/ubuntu questing/main s390x openssh-sftp-server s390x 1:9.9p1-3ubuntu3.1 [38.2 kB] 92s Get:7 http://ftpmaster.internal/ubuntu questing/main s390x openssh-server s390x 1:9.9p1-3ubuntu3.1 [552 kB] 92s Get:8 http://ftpmaster.internal/ubuntu questing/main s390x openssh-client s390x 1:9.9p1-3ubuntu3.1 [954 kB] 92s Get:9 http://ftpmaster.internal/ubuntu questing/main s390x libatomic1 s390x 15.1.0-2ubuntu1 [9564 B] 92s Get:10 http://ftpmaster.internal/ubuntu questing/main s390x gcc-15-base s390x 15.1.0-2ubuntu1 [54.6 kB] 92s Get:11 http://ftpmaster.internal/ubuntu questing/main s390x libgcc-s1 s390x 15.1.0-2ubuntu1 [35.7 kB] 92s Get:12 http://ftpmaster.internal/ubuntu questing/main s390x libstdc++6 s390x 15.1.0-2ubuntu1 [906 kB] 92s Get:13 http://ftpmaster.internal/ubuntu questing/main s390x libsemanage-common all 3.8.1-1 [7826 B] 92s Get:14 http://ftpmaster.internal/ubuntu questing/main s390x libsemanage2 s390x 3.8.1-1 [99.9 kB] 92s Get:15 http://ftpmaster.internal/ubuntu questing/main s390x gpg-wks-client s390x 2.4.4-2ubuntu24 [75.6 kB] 92s Get:16 http://ftpmaster.internal/ubuntu questing/main s390x dirmngr s390x 2.4.4-2ubuntu24 [341 kB] 92s Get:17 http://ftpmaster.internal/ubuntu questing/main s390x gpgsm s390x 2.4.4-2ubuntu24 [244 kB] 92s Get:18 http://ftpmaster.internal/ubuntu questing/main s390x gnupg-utils s390x 2.4.4-2ubuntu24 [116 kB] 92s Get:19 http://ftpmaster.internal/ubuntu questing/main s390x gpg-agent s390x 2.4.4-2ubuntu24 [240 kB] 92s Get:20 http://ftpmaster.internal/ubuntu questing/main s390x gpg s390x 2.4.4-2ubuntu24 [591 kB] 92s Get:21 http://ftpmaster.internal/ubuntu questing/main s390x gpgconf s390x 2.4.4-2ubuntu24 [110 kB] 92s Get:22 http://ftpmaster.internal/ubuntu questing/main s390x gnupg all 2.4.4-2ubuntu24 [359 kB] 92s Get:23 http://ftpmaster.internal/ubuntu questing/main s390x keyboxd s390x 2.4.4-2ubuntu24 [82.0 kB] 92s Get:24 http://ftpmaster.internal/ubuntu questing/main s390x gpgv s390x 2.4.4-2ubuntu24 [164 kB] 92s Get:25 http://ftpmaster.internal/ubuntu questing/main s390x sensible-utils all 0.0.25 [25.0 kB] 92s Get:26 http://ftpmaster.internal/ubuntu questing/main s390x dhcpcd-base s390x 1:10.1.0-10 [220 kB] 92s Get:27 http://ftpmaster.internal/ubuntu questing/main s390x gir1.2-glib-2.0 s390x 2.84.1-2 [182 kB] 92s Get:28 http://ftpmaster.internal/ubuntu questing/main s390x libglib2.0-0t64 s390x 2.84.1-2 [1587 kB] 93s Get:29 http://ftpmaster.internal/ubuntu questing/main s390x libdebuginfod1t64 s390x 0.193-1 [22.5 kB] 93s Get:30 http://ftpmaster.internal/ubuntu questing/main s390x libdw1t64 s390x 0.193-1 [305 kB] 93s Get:31 http://ftpmaster.internal/ubuntu questing/main s390x libelf1t64 s390x 0.193-1 [70.4 kB] 93s Get:32 http://ftpmaster.internal/ubuntu questing/main s390x libglib2.0-data all 2.84.1-2 [53.2 kB] 93s Get:33 http://ftpmaster.internal/ubuntu questing/main s390x libxml2 s390x 2.12.7+dfsg+really2.9.14-0.4ubuntu0.1 [816 kB] 93s Get:34 http://ftpmaster.internal/ubuntu questing/main s390x python3-dbus s390x 1.4.0-1 [102 kB] 93s Get:35 http://ftpmaster.internal/ubuntu questing/main s390x libnuma1 s390x 2.0.19-1 [24.6 kB] 93s Get:36 http://ftpmaster.internal/ubuntu questing/main s390x libx11-data all 2:1.8.12-1 [116 kB] 93s Get:37 http://ftpmaster.internal/ubuntu questing/main s390x libx11-6 s390x 2:1.8.12-1 [671 kB] 93s Get:38 http://ftpmaster.internal/ubuntu questing/main s390x numactl s390x 2.0.19-1 [39.3 kB] 93s Get:39 http://ftpmaster.internal/ubuntu questing/main s390x gnupg-l10n all 2.4.4-2ubuntu24 [66.8 kB] 93s Get:40 http://ftpmaster.internal/ubuntu questing-proposed/universe s390x libpython3.12t64 s390x 3.12.10-1 [2509 kB] 93s Get:41 http://ftpmaster.internal/ubuntu questing-proposed/universe s390x libpython3.12-stdlib s390x 3.12.10-1 [2049 kB] 93s Get:42 http://ftpmaster.internal/ubuntu questing-proposed/universe s390x libpython3.12-minimal s390x 3.12.10-1 [836 kB] 93s Get:43 http://ftpmaster.internal/ubuntu questing/main s390x lto-disabled-list all 58 [12.4 kB] 93s Get:44 http://ftpmaster.internal/ubuntu questing/main s390x python3-wadllib all 2.0.0-3 [36.3 kB] 93s Preconfiguring packages ... 93s Fetched 25.1 MB in 3s (8376 kB/s) 93s (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 ... 81479 files and directories currently installed.) 93s Preparing to unpack .../libperl5.40_5.40.1-3_s390x.deb ... 93s Unpacking libperl5.40:s390x (5.40.1-3) over (5.40.1-2) ... 94s Preparing to unpack .../perl_5.40.1-3_s390x.deb ... 94s Unpacking perl (5.40.1-3) over (5.40.1-2) ... 94s Preparing to unpack .../perl-base_5.40.1-3_s390x.deb ... 94s Unpacking perl-base (5.40.1-3) over (5.40.1-2) ... 94s Setting up perl-base (5.40.1-3) ... 94s (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 ... 81479 files and directories currently installed.) 94s Preparing to unpack .../0-perl-modules-5.40_5.40.1-3_all.deb ... 94s Unpacking perl-modules-5.40 (5.40.1-3) over (5.40.1-2) ... 94s Preparing to unpack .../1-libdebuginfod-common_0.193-1_all.deb ... 94s Unpacking libdebuginfod-common (0.193-1) over (0.192-4ubuntu1) ... 94s Preparing to unpack .../2-openssh-sftp-server_1%3a9.9p1-3ubuntu3.1_s390x.deb ... 94s Unpacking openssh-sftp-server (1:9.9p1-3ubuntu3.1) over (1:9.9p1-3ubuntu3) ... 94s Preparing to unpack .../3-openssh-server_1%3a9.9p1-3ubuntu3.1_s390x.deb ... 94s Unpacking openssh-server (1:9.9p1-3ubuntu3.1) over (1:9.9p1-3ubuntu3) ... 94s Preparing to unpack .../4-openssh-client_1%3a9.9p1-3ubuntu3.1_s390x.deb ... 94s Unpacking openssh-client (1:9.9p1-3ubuntu3.1) over (1:9.9p1-3ubuntu3) ... 94s Preparing to unpack .../5-libatomic1_15.1.0-2ubuntu1_s390x.deb ... 94s Unpacking libatomic1:s390x (15.1.0-2ubuntu1) over (15-20250404-0ubuntu1) ... 94s Preparing to unpack .../6-gcc-15-base_15.1.0-2ubuntu1_s390x.deb ... 94s Unpacking gcc-15-base:s390x (15.1.0-2ubuntu1) over (15-20250404-0ubuntu1) ... 94s Setting up gcc-15-base:s390x (15.1.0-2ubuntu1) ... 94s (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 ... 81479 files and directories currently installed.) 94s Preparing to unpack .../libgcc-s1_15.1.0-2ubuntu1_s390x.deb ... 94s Unpacking libgcc-s1:s390x (15.1.0-2ubuntu1) over (15-20250404-0ubuntu1) ... 94s Setting up libgcc-s1:s390x (15.1.0-2ubuntu1) ... 94s (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 ... 81479 files and directories currently installed.) 94s Preparing to unpack .../libstdc++6_15.1.0-2ubuntu1_s390x.deb ... 94s Unpacking libstdc++6:s390x (15.1.0-2ubuntu1) over (15-20250404-0ubuntu1) ... 94s Setting up libstdc++6:s390x (15.1.0-2ubuntu1) ... 94s (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 ... 81479 files and directories currently installed.) 94s Preparing to unpack .../libsemanage-common_3.8.1-1_all.deb ... 94s Unpacking libsemanage-common (3.8.1-1) over (3.7-2.1build1) ... 94s Setting up libsemanage-common (3.8.1-1) ... 94s (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 ... 81479 files and directories currently installed.) 94s Preparing to unpack .../libsemanage2_3.8.1-1_s390x.deb ... 94s Unpacking libsemanage2:s390x (3.8.1-1) over (3.7-2.1build1) ... 94s Setting up libsemanage2:s390x (3.8.1-1) ... 94s (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 ... 81479 files and directories currently installed.) 94s Preparing to unpack .../0-gpg-wks-client_2.4.4-2ubuntu24_s390x.deb ... 94s Unpacking gpg-wks-client (2.4.4-2ubuntu24) over (2.4.4-2ubuntu23) ... 94s Preparing to unpack .../1-dirmngr_2.4.4-2ubuntu24_s390x.deb ... 94s Unpacking dirmngr (2.4.4-2ubuntu24) over (2.4.4-2ubuntu23) ... 94s Preparing to unpack .../2-gpgsm_2.4.4-2ubuntu24_s390x.deb ... 94s Unpacking gpgsm (2.4.4-2ubuntu24) over (2.4.4-2ubuntu23) ... 94s Preparing to unpack .../3-gnupg-utils_2.4.4-2ubuntu24_s390x.deb ... 94s Unpacking gnupg-utils (2.4.4-2ubuntu24) over (2.4.4-2ubuntu23) ... 94s Preparing to unpack .../4-gpg-agent_2.4.4-2ubuntu24_s390x.deb ... 94s Unpacking gpg-agent (2.4.4-2ubuntu24) over (2.4.4-2ubuntu23) ... 94s Preparing to unpack .../5-gpg_2.4.4-2ubuntu24_s390x.deb ... 94s Unpacking gpg (2.4.4-2ubuntu24) over (2.4.4-2ubuntu23) ... 94s Preparing to unpack .../6-gpgconf_2.4.4-2ubuntu24_s390x.deb ... 94s Unpacking gpgconf (2.4.4-2ubuntu24) over (2.4.4-2ubuntu23) ... 95s Preparing to unpack .../7-gnupg_2.4.4-2ubuntu24_all.deb ... 95s Unpacking gnupg (2.4.4-2ubuntu24) over (2.4.4-2ubuntu23) ... 95s Preparing to unpack .../8-keyboxd_2.4.4-2ubuntu24_s390x.deb ... 95s Unpacking keyboxd (2.4.4-2ubuntu24) over (2.4.4-2ubuntu23) ... 95s Preparing to unpack .../9-gpgv_2.4.4-2ubuntu24_s390x.deb ... 95s Unpacking gpgv (2.4.4-2ubuntu24) over (2.4.4-2ubuntu23) ... 95s Setting up gpgv (2.4.4-2ubuntu24) ... 95s (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 ... 81479 files and directories currently installed.) 95s Preparing to unpack .../00-sensible-utils_0.0.25_all.deb ... 95s Unpacking sensible-utils (0.0.25) over (0.0.24) ... 95s Preparing to unpack .../01-dhcpcd-base_1%3a10.1.0-10_s390x.deb ... 95s Unpacking dhcpcd-base (1:10.1.0-10) over (1:10.1.0-8) ... 95s Preparing to unpack .../02-gir1.2-glib-2.0_2.84.1-2_s390x.deb ... 95s Unpacking gir1.2-glib-2.0:s390x (2.84.1-2) over (2.84.1-1) ... 95s Preparing to unpack .../03-libglib2.0-0t64_2.84.1-2_s390x.deb ... 95s Unpacking libglib2.0-0t64:s390x (2.84.1-2) over (2.84.1-1) ... 95s Preparing to unpack .../04-libdebuginfod1t64_0.193-1_s390x.deb ... 95s Unpacking libdebuginfod1t64:s390x (0.193-1) over (0.192-4ubuntu1) ... 95s Preparing to unpack .../05-libdw1t64_0.193-1_s390x.deb ... 95s Unpacking libdw1t64:s390x (0.193-1) over (0.192-4ubuntu1) ... 95s Preparing to unpack .../06-libelf1t64_0.193-1_s390x.deb ... 95s Unpacking libelf1t64:s390x (0.193-1) over (0.192-4ubuntu1) ... 95s Preparing to unpack .../07-libglib2.0-data_2.84.1-2_all.deb ... 95s Unpacking libglib2.0-data (2.84.1-2) over (2.84.1-1) ... 95s Preparing to unpack .../08-libxml2_2.12.7+dfsg+really2.9.14-0.4ubuntu0.1_s390x.deb ... 95s Unpacking libxml2:s390x (2.12.7+dfsg+really2.9.14-0.4ubuntu0.1) over (2.12.7+dfsg+really2.9.14-0.4) ... 95s Preparing to unpack .../09-python3-dbus_1.4.0-1_s390x.deb ... 95s Unpacking python3-dbus (1.4.0-1) over (1.3.2-5build5) ... 95s Preparing to unpack .../10-libnuma1_2.0.19-1_s390x.deb ... 95s Unpacking libnuma1:s390x (2.0.19-1) over (2.0.18-1build1) ... 95s Preparing to unpack .../11-libx11-data_2%3a1.8.12-1_all.deb ... 95s Unpacking libx11-data (2:1.8.12-1) over (2:1.8.10-2) ... 95s Preparing to unpack .../12-libx11-6_2%3a1.8.12-1_s390x.deb ... 95s Unpacking libx11-6:s390x (2:1.8.12-1) over (2:1.8.10-2) ... 95s Preparing to unpack .../13-numactl_2.0.19-1_s390x.deb ... 95s Unpacking numactl (2.0.19-1) over (2.0.18-1build1) ... 95s Preparing to unpack .../14-gnupg-l10n_2.4.4-2ubuntu24_all.deb ... 95s Unpacking gnupg-l10n (2.4.4-2ubuntu24) over (2.4.4-2ubuntu23) ... 95s Preparing to unpack .../15-libpython3.12t64_3.12.10-1_s390x.deb ... 95s Unpacking libpython3.12t64:s390x (3.12.10-1) over (3.12.8-3) ... 95s Preparing to unpack .../16-libpython3.12-stdlib_3.12.10-1_s390x.deb ... 95s Unpacking libpython3.12-stdlib:s390x (3.12.10-1) over (3.12.8-3) ... 95s Preparing to unpack .../17-libpython3.12-minimal_3.12.10-1_s390x.deb ... 95s Unpacking libpython3.12-minimal:s390x (3.12.10-1) over (3.12.8-3) ... 95s Preparing to unpack .../18-lto-disabled-list_58_all.deb ... 95s Unpacking lto-disabled-list (58) over (57) ... 95s Preparing to unpack .../19-python3-wadllib_2.0.0-3_all.deb ... 95s Unpacking python3-wadllib (2.0.0-3) over (2.0.0-2) ... 95s Setting up lto-disabled-list (58) ... 95s Setting up libdebuginfod-common (0.193-1) ... 95s Setting up openssh-client (1:9.9p1-3ubuntu3.1) ... 95s Setting up libpython3.12-minimal:s390x (3.12.10-1) ... 95s Setting up libelf1t64:s390x (0.193-1) ... 95s Setting up libdw1t64:s390x (0.193-1) ... 95s Setting up libglib2.0-data (2.84.1-2) ... 95s Setting up libx11-data (2:1.8.12-1) ... 95s Setting up gnupg-l10n (2.4.4-2ubuntu24) ... 95s Setting up python3-wadllib (2.0.0-3) ... 95s Setting up libatomic1:s390x (15.1.0-2ubuntu1) ... 95s Setting up dhcpcd-base (1:10.1.0-10) ... 95s Installing new version of config file /etc/dhcpcd.conf ... 95s Setting up libnuma1:s390x (2.0.19-1) ... 95s Setting up perl-modules-5.40 (5.40.1-3) ... 95s Setting up sensible-utils (0.0.25) ... 95s Setting up gpgconf (2.4.4-2ubuntu24) ... 95s Setting up libx11-6:s390x (2:1.8.12-1) ... 95s Setting up libxml2:s390x (2.12.7+dfsg+really2.9.14-0.4ubuntu0.1) ... 95s Setting up gpg (2.4.4-2ubuntu24) ... 95s Setting up gnupg-utils (2.4.4-2ubuntu24) ... 95s Setting up openssh-sftp-server (1:9.9p1-3ubuntu3.1) ... 95s Setting up libdebuginfod1t64:s390x (0.193-1) ... 95s Setting up gpg-agent (2.4.4-2ubuntu24) ... 96s Setting up libpython3.12-stdlib:s390x (3.12.10-1) ... 96s Setting up numactl (2.0.19-1) ... 96s Setting up openssh-server (1:9.9p1-3ubuntu3.1) ... 97s Setting up gpgsm (2.4.4-2ubuntu24) ... 97s Setting up libpython3.12t64:s390x (3.12.10-1) ... 97s Setting up libperl5.40:s390x (5.40.1-3) ... 97s Setting up dirmngr (2.4.4-2ubuntu24) ... 97s Setting up perl (5.40.1-3) ... 97s Setting up libglib2.0-0t64:s390x (2.84.1-2) ... 97s No schema files found: doing nothing. 97s Setting up keyboxd (2.4.4-2ubuntu24) ... 97s Setting up gir1.2-glib-2.0:s390x (2.84.1-2) ... 97s Setting up gnupg (2.4.4-2ubuntu24) ... 97s Setting up python3-dbus (1.4.0-1) ... 97s Setting up gpg-wks-client (2.4.4-2ubuntu24) ... 97s Processing triggers for ufw (0.36.2-9) ... 97s Processing triggers for man-db (2.13.1-1) ... 98s Processing triggers for install-info (7.1.1-1) ... 98s Processing triggers for libc-bin (2.41-6ubuntu1) ... 98s Reading package lists... 98s Building dependency tree... 98s Reading state information... 98s Starting pkgProblemResolver with broken count: 0 98s Starting 2 pkgProblemResolver with broken count: 0 98s Done 99s Solving dependencies... 99s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 99s autopkgtest [17:25:19]: rebooting testbed after setup commands that affected boot 103s autopkgtest-virt-ssh: WARNING: ssh connection failed. Retrying in 3 seconds... 117s autopkgtest [17:25:37]: testbed running kernel: Linux 6.14.0-15-generic #15-Ubuntu SMP Sun Apr 6 13:39:00 UTC 2025 119s autopkgtest [17:25:39]: @@@@@@@@@@@@@@@@@@@@ apt-source pandas 122s Get:1 http://ftpmaster.internal/ubuntu questing/universe pandas 2.2.3+dfsg-9 (dsc) [5546 B] 122s Get:2 http://ftpmaster.internal/ubuntu questing/universe pandas 2.2.3+dfsg-9 (tar) [11.2 MB] 122s Get:3 http://ftpmaster.internal/ubuntu questing/universe pandas 2.2.3+dfsg-9 (diff) [112 kB] 122s gpgv: Signature made Sat Mar 29 14:46:18 2025 UTC 122s gpgv: using RSA key 67CB311005C4EDBE32175308DEE50D0D567EA266 122s gpgv: issuer "rebecca_palmer@zoho.com" 122s gpgv: Can't check signature: No public key 122s dpkg-source: warning: cannot verify inline signature for ./pandas_2.2.3+dfsg-9.dsc: no acceptable signature found 123s autopkgtest [17:25:43]: testing package pandas version 2.2.3+dfsg-9 124s autopkgtest [17:25:44]: build not needed 130s autopkgtest [17:25:50]: test command1: preparing testbed 131s Reading package lists... 131s Building dependency tree... 131s Reading state information... 131s Starting pkgProblemResolver with broken count: 0 131s Starting 2 pkgProblemResolver with broken count: 0 131s Done 131s The following NEW packages will be installed: 131s libblas3 libgfortran5 liblapack3 python3-dateutil python3-numpy 131s python3-numpy-dev python3-pandas python3-pandas-lib python3-pytz 131s 0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded. 131s Need to get 16.7 MB of archives. 131s After this operation, 80.7 MB of additional disk space will be used. 131s Get:1 http://ftpmaster.internal/ubuntu questing/main s390x python3-numpy-dev s390x 1:2.2.4+ds-1 [147 kB] 131s Get:2 http://ftpmaster.internal/ubuntu questing/main s390x libblas3 s390x 3.12.1-2 [252 kB] 132s Get:3 http://ftpmaster.internal/ubuntu questing/main s390x libgfortran5 s390x 15.1.0-2ubuntu1 [614 kB] 132s Get:4 http://ftpmaster.internal/ubuntu questing/main s390x liblapack3 s390x 3.12.1-2 [2971 kB] 132s Get:5 http://ftpmaster.internal/ubuntu questing/main s390x python3-numpy s390x 1:2.2.4+ds-1 [4404 kB] 132s Get:6 http://ftpmaster.internal/ubuntu questing/main s390x python3-dateutil all 2.9.0-4 [80.3 kB] 132s Get:7 http://ftpmaster.internal/ubuntu questing/main s390x python3-pytz all 2025.1-3 [162 kB] 132s Get:8 http://ftpmaster.internal/ubuntu questing/universe s390x python3-pandas-lib s390x 2.2.3+dfsg-9 [4991 kB] 132s Get:9 http://ftpmaster.internal/ubuntu questing/universe s390x python3-pandas all 2.2.3+dfsg-9 [3112 kB] 133s Fetched 16.7 MB in 2s (10.7 MB/s) 133s Selecting previously unselected package python3-numpy-dev:s390x. 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 ... 81479 files and directories currently installed.) 133s Preparing to unpack .../0-python3-numpy-dev_1%3a2.2.4+ds-1_s390x.deb ... 133s Unpacking python3-numpy-dev:s390x (1:2.2.4+ds-1) ... 133s Selecting previously unselected package libblas3:s390x. 133s Preparing to unpack .../1-libblas3_3.12.1-2_s390x.deb ... 133s Unpacking libblas3:s390x (3.12.1-2) ... 133s Selecting previously unselected package libgfortran5:s390x. 133s Preparing to unpack .../2-libgfortran5_15.1.0-2ubuntu1_s390x.deb ... 133s Unpacking libgfortran5:s390x (15.1.0-2ubuntu1) ... 133s Selecting previously unselected package liblapack3:s390x. 133s Preparing to unpack .../3-liblapack3_3.12.1-2_s390x.deb ... 133s Unpacking liblapack3:s390x (3.12.1-2) ... 133s Selecting previously unselected package python3-numpy. 133s Preparing to unpack .../4-python3-numpy_1%3a2.2.4+ds-1_s390x.deb ... 133s Unpacking python3-numpy (1:2.2.4+ds-1) ... 133s Selecting previously unselected package python3-dateutil. 133s Preparing to unpack .../5-python3-dateutil_2.9.0-4_all.deb ... 133s Unpacking python3-dateutil (2.9.0-4) ... 133s Selecting previously unselected package python3-pytz. 133s Preparing to unpack .../6-python3-pytz_2025.1-3_all.deb ... 133s Unpacking python3-pytz (2025.1-3) ... 133s Selecting previously unselected package python3-pandas-lib:s390x. 133s Preparing to unpack .../7-python3-pandas-lib_2.2.3+dfsg-9_s390x.deb ... 133s Unpacking python3-pandas-lib:s390x (2.2.3+dfsg-9) ... 133s Selecting previously unselected package python3-pandas. 133s Preparing to unpack .../8-python3-pandas_2.2.3+dfsg-9_all.deb ... 133s Unpacking python3-pandas (2.2.3+dfsg-9) ... 133s Setting up python3-pytz (2025.1-3) ... 134s Setting up libblas3:s390x (3.12.1-2) ... 134s update-alternatives: using /usr/lib/s390x-linux-gnu/blas/libblas.so.3 to provide /usr/lib/s390x-linux-gnu/libblas.so.3 (libblas.so.3-s390x-linux-gnu) in auto mode 134s Setting up python3-numpy-dev:s390x (1:2.2.4+ds-1) ... 134s Setting up libgfortran5:s390x (15.1.0-2ubuntu1) ... 134s Setting up python3-dateutil (2.9.0-4) ... 134s Setting up liblapack3:s390x (3.12.1-2) ... 134s update-alternatives: using /usr/lib/s390x-linux-gnu/lapack/liblapack.so.3 to provide /usr/lib/s390x-linux-gnu/liblapack.so.3 (liblapack.so.3-s390x-linux-gnu) in auto mode 134s Setting up python3-numpy (1:2.2.4+ds-1) ... 135s Setting up python3-pandas-lib:s390x (2.2.3+dfsg-9) ... 135s Setting up python3-pandas (2.2.3+dfsg-9) ... 138s Processing triggers for man-db (2.13.1-1) ... 139s Processing triggers for libc-bin (2.41-6ubuntu1) ... 140s autopkgtest [17:26:00]: test command1: cd "$AUTOPKGTEST_TMP" && python3 -c "import pandas;a=pandas.DataFrame([[1,2],[3,4]])" 140s autopkgtest [17:26:00]: test command1: [----------------------- 141s autopkgtest [17:26:01]: test command1: -----------------------] 141s autopkgtest [17:26:01]: test command1: - - - - - - - - - - results - - - - - - - - - - 141s command1 PASS 141s autopkgtest [17:26:01]: test unittests3: preparing testbed 142s Reading package lists... 142s Building dependency tree... 142s Reading state information... 142s Starting pkgProblemResolver with broken count: 0 142s Starting 2 pkgProblemResolver with broken count: 0 142s Done 142s The following NEW packages will be installed: 142s blt fontconfig fontconfig-config fonts-dejavu-core fonts-dejavu-mono 142s fonts-lyx libavahi-client3 libavahi-common-data libavahi-common3 libcups2t64 142s libdeflate0 libdouble-conversion3 libegl-mesa0 libegl1 libfontconfig1 142s libfontenc1 libfreetype6 libgbm1 libgl1 libgl1-mesa-dri libglvnd0 142s libglx-mesa0 libglx0 libgomp1 libgraphite2-3 libharfbuzz0b libice6 142s libimagequant0 libinput-bin libinput10 libjbig0 libjpeg-turbo8 libjpeg8 142s libjs-jquery libjs-jquery-ui liblbfgsb0 liblcms2-2 libmd4c0 libmtdev1t64 142s libopenjp2-7 libpcre2-16-0 libpixman-1-0 libqhull-r8.0 libqt5core5t64 142s libqt5dbus5t64 libqt5designer5 libqt5gui5t64 libqt5help5 libqt5network5t64 142s libqt5printsupport5t64 libqt5sql5t64 libqt5test5t64 libqt5widgets5t64 142s libqt5xml5t64 libraqm0 libsharpyuv0 libsm6 libtcl8.6 libtiff6 libtk8.6 142s libvulkan1 libwacom-common libwacom9 libwayland-client0 libwayland-server0 142s libwebp7 libwebpdemux2 libwebpmux3 libx11-xcb1 libxaw7 libxcb-dri3-0 142s libxcb-glx0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-present0 142s libxcb-randr0 libxcb-render-util0 libxcb-render0 libxcb-shape0 libxcb-shm0 142s libxcb-sync1 libxcb-util1 libxcb-xfixes0 libxcb-xinerama0 libxcb-xinput0 142s libxcb-xkb1 libxfont2 libxft2 libxkbcommon-x11-0 libxkbfile1 libxmu6 libxpm4 142s libxrandr2 libxrender1 libxshmfence1 libxslt1.1 libxss1 libxt6t64 142s libxxf86vm1 locales-all mesa-libgallium python-matplotlib-data python3-all 142s python3-async-generator python3-bottleneck python3-brotli python3-bs4 142s python3-click python3-cloudpickle python3-contourpy python3-cycler 142s python3-dask python3-decorator python3-defusedxml python3-et-xmlfile 142s python3-execnet python3-fonttools python3-fs python3-fsspec python3-greenlet 142s python3-html5lib python3-hypothesis python3-iniconfig python3-kiwisolver 142s python3-locket python3-lxml python3-lz4 python3-matplotlib python3-mpmath 142s python3-numexpr python3-odf python3-openpyxl python3-packaging python3-partd 142s python3-pil python3-pil.imagetk python3-platformdirs python3-pluggy 142s python3-py python3-pyqt5 python3-pyqt5.sip python3-pyreadstat python3-pytest 142s python3-pytest-asyncio python3-pytest-forked python3-pytest-localserver 142s python3-pytest-xdist python3-pytestqt python3-scipy python3-sortedcontainers 142s python3-soupsieve python3-sqlalchemy python3-sympy python3-tabulate 142s python3-tk python3-toolz python3-tz python3-ufolib2 python3-webencodings 142s python3-werkzeug python3-xarray python3-xlrd python3-xlsxwriter 142s python3-zstandard python3.13-tk tk8.6-blt2.5 tzdata-legacy unicode-data 142s x11-common x11-xkb-utils xsel xserver-common xvfb 142s 0 upgraded, 174 newly installed, 0 to remove and 0 not upgraded. 142s Need to get 112 MB of archives. 142s After this operation, 646 MB of additional disk space will be used. 142s Get:1 http://ftpmaster.internal/ubuntu questing/main s390x libtcl8.6 s390x 8.6.16+dfsg-1 [1034 kB] 143s Get:2 http://ftpmaster.internal/ubuntu questing/main s390x libfreetype6 s390x 2.13.3+dfsg-1 [431 kB] 143s Get:3 http://ftpmaster.internal/ubuntu questing/main s390x fonts-dejavu-mono all 2.37-8 [502 kB] 143s Get:4 http://ftpmaster.internal/ubuntu questing/main s390x fonts-dejavu-core all 2.37-8 [835 kB] 143s Get:5 http://ftpmaster.internal/ubuntu questing/main s390x fontconfig-config s390x 2.15.0-2.2ubuntu1 [37.9 kB] 143s Get:6 http://ftpmaster.internal/ubuntu questing/main s390x libfontconfig1 s390x 2.15.0-2.2ubuntu1 [150 kB] 143s Get:7 http://ftpmaster.internal/ubuntu questing/main s390x libxrender1 s390x 1:0.9.12-1 [20.9 kB] 143s Get:8 http://ftpmaster.internal/ubuntu questing/main s390x libxft2 s390x 2.3.6-1build1 [49.6 kB] 143s Get:9 http://ftpmaster.internal/ubuntu questing/main s390x x11-common all 1:7.7+23ubuntu4 [21.8 kB] 143s Get:10 http://ftpmaster.internal/ubuntu questing/main s390x libxss1 s390x 1:1.2.3-1build3 [7396 B] 143s Get:11 http://ftpmaster.internal/ubuntu questing/main s390x libtk8.6 s390x 8.6.16-1 [830 kB] 143s Get:12 http://ftpmaster.internal/ubuntu questing/main s390x tk8.6-blt2.5 s390x 2.5.3+dfsg-8 [657 kB] 143s Get:13 http://ftpmaster.internal/ubuntu questing/main s390x blt s390x 2.5.3+dfsg-8 [4826 B] 143s Get:14 http://ftpmaster.internal/ubuntu questing/main s390x fontconfig s390x 2.15.0-2.2ubuntu1 [191 kB] 143s Get:15 http://ftpmaster.internal/ubuntu questing/universe s390x fonts-lyx all 2.4.3-1 [171 kB] 143s Get:16 http://ftpmaster.internal/ubuntu questing/main s390x libavahi-common-data s390x 0.8-16ubuntu2 [31.0 kB] 143s Get:17 http://ftpmaster.internal/ubuntu questing/main s390x libavahi-common3 s390x 0.8-16ubuntu2 [23.5 kB] 143s Get:18 http://ftpmaster.internal/ubuntu questing/main s390x libavahi-client3 s390x 0.8-16ubuntu2 [26.3 kB] 143s Get:19 http://ftpmaster.internal/ubuntu questing/main s390x libcups2t64 s390x 2.4.12-0ubuntu1 [282 kB] 143s Get:20 http://ftpmaster.internal/ubuntu questing/main s390x libdeflate0 s390x 1.23-2 [46.0 kB] 143s Get:21 http://ftpmaster.internal/ubuntu questing/universe s390x libdouble-conversion3 s390x 3.3.1-1 [43.3 kB] 143s Get:22 http://ftpmaster.internal/ubuntu questing/main s390x libwayland-server0 s390x 1.23.1-3 [37.3 kB] 143s Get:23 http://ftpmaster.internal/ubuntu questing/main s390x libx11-xcb1 s390x 2:1.8.12-1 [7944 B] 143s Get:24 http://ftpmaster.internal/ubuntu questing/main s390x libxcb-dri3-0 s390x 1.17.0-2 [7616 B] 143s Get:25 http://ftpmaster.internal/ubuntu questing/main s390x libxcb-present0 s390x 1.17.0-2 [6244 B] 143s Get:26 http://ftpmaster.internal/ubuntu questing/main s390x libxcb-randr0 s390x 1.17.0-2 [19.2 kB] 143s Get:27 http://ftpmaster.internal/ubuntu questing/main s390x libxcb-sync1 s390x 1.17.0-2 [9488 B] 143s Get:28 http://ftpmaster.internal/ubuntu questing/main s390x libxcb-xfixes0 s390x 1.17.0-2 [10.5 kB] 143s Get:29 http://ftpmaster.internal/ubuntu questing/main s390x libxshmfence1 s390x 1.3.3-1 [5202 B] 143s Get:30 http://ftpmaster.internal/ubuntu questing/main s390x mesa-libgallium s390x 25.0.3-1ubuntu2 [8057 kB] 144s Get:31 http://ftpmaster.internal/ubuntu questing/main s390x libgbm1 s390x 25.0.3-1ubuntu2 [34.5 kB] 144s Get:32 http://ftpmaster.internal/ubuntu questing/main s390x libwayland-client0 s390x 1.23.1-3 [28.2 kB] 144s Get:33 http://ftpmaster.internal/ubuntu questing/main s390x libxcb-shm0 s390x 1.17.0-2 [5862 B] 144s Get:34 http://ftpmaster.internal/ubuntu questing/main s390x libegl-mesa0 s390x 25.0.3-1ubuntu2 [127 kB] 144s Get:35 http://ftpmaster.internal/ubuntu questing/main s390x libfontenc1 s390x 1:1.1.8-1build1 [14.8 kB] 144s Get:36 http://ftpmaster.internal/ubuntu questing/main s390x libvulkan1 s390x 1.4.309.0-1 [145 kB] 144s Get:37 http://ftpmaster.internal/ubuntu questing/main s390x libgl1-mesa-dri s390x 25.0.3-1ubuntu2 [35.5 kB] 144s Get:38 http://ftpmaster.internal/ubuntu questing/main s390x libxcb-glx0 s390x 1.17.0-2 [26.0 kB] 144s Get:39 http://ftpmaster.internal/ubuntu questing/main s390x libxxf86vm1 s390x 1:1.1.4-1build4 [9630 B] 144s Get:40 http://ftpmaster.internal/ubuntu questing/main s390x libglx-mesa0 s390x 25.0.3-1ubuntu2 [161 kB] 144s Get:41 http://ftpmaster.internal/ubuntu questing/main s390x libgomp1 s390x 15.1.0-2ubuntu1 [153 kB] 144s Get:42 http://ftpmaster.internal/ubuntu questing/main s390x libgraphite2-3 s390x 1.3.14-2ubuntu1 [79.8 kB] 144s Get:43 http://ftpmaster.internal/ubuntu questing/main s390x libharfbuzz0b s390x 10.2.0-1 [538 kB] 144s Get:44 http://ftpmaster.internal/ubuntu questing/main s390x libice6 s390x 2:1.1.1-1 [45.4 kB] 144s Get:45 http://ftpmaster.internal/ubuntu questing/main s390x libimagequant0 s390x 2.18.0-1build1 [43.3 kB] 144s Get:46 http://ftpmaster.internal/ubuntu questing/main s390x libwacom-common all 2.14.0-1 [103 kB] 144s Get:47 http://ftpmaster.internal/ubuntu questing/main s390x libwacom9 s390x 2.14.0-1 [27.1 kB] 144s Get:48 http://ftpmaster.internal/ubuntu questing/main s390x libinput-bin s390x 1.28.1-1 [23.7 kB] 144s Get:49 http://ftpmaster.internal/ubuntu questing/main s390x libmtdev1t64 s390x 1.1.7-1 [15.6 kB] 144s Get:50 http://ftpmaster.internal/ubuntu questing/main s390x libinput10 s390x 1.28.1-1 [142 kB] 144s Get:51 http://ftpmaster.internal/ubuntu questing/main s390x libjpeg-turbo8 s390x 2.1.5-3ubuntu2 [147 kB] 144s Get:52 http://ftpmaster.internal/ubuntu questing/main s390x libjpeg8 s390x 8c-2ubuntu11 [2146 B] 144s Get:53 http://ftpmaster.internal/ubuntu questing/main s390x libjs-jquery all 3.6.1+dfsg+~3.5.14-1 [328 kB] 144s Get:54 http://ftpmaster.internal/ubuntu questing/universe s390x libjs-jquery-ui all 1.13.2+dfsg-1 [252 kB] 144s Get:55 http://ftpmaster.internal/ubuntu questing/universe s390x liblbfgsb0 s390x 3.0+dfsg.4-1build1 [32.4 kB] 144s Get:56 http://ftpmaster.internal/ubuntu questing/main s390x liblcms2-2 s390x 2.16-2 [175 kB] 144s Get:57 http://ftpmaster.internal/ubuntu questing/universe s390x libmd4c0 s390x 0.5.2-2 [47.7 kB] 144s Get:58 http://ftpmaster.internal/ubuntu questing/main s390x libpcre2-16-0 s390x 10.45-1 [259 kB] 144s Get:59 http://ftpmaster.internal/ubuntu questing/main s390x libpixman-1-0 s390x 0.44.0-3 [201 kB] 144s Get:60 http://ftpmaster.internal/ubuntu questing/universe s390x libqhull-r8.0 s390x 2020.2-6build1 [199 kB] 144s Get:61 http://ftpmaster.internal/ubuntu questing/universe s390x libqt5core5t64 s390x 5.15.15+dfsg-4ubuntu1 [2242 kB] 145s Get:62 http://ftpmaster.internal/ubuntu questing/universe s390x libqt5dbus5t64 s390x 5.15.15+dfsg-4ubuntu1 [240 kB] 145s Get:63 http://ftpmaster.internal/ubuntu questing/main s390x libglvnd0 s390x 1.7.0-1build1 [110 kB] 145s Get:64 http://ftpmaster.internal/ubuntu questing/main s390x libegl1 s390x 1.7.0-1build1 [31.8 kB] 145s Get:65 http://ftpmaster.internal/ubuntu questing/main s390x libglx0 s390x 1.7.0-1build1 [32.2 kB] 145s Get:66 http://ftpmaster.internal/ubuntu questing/main s390x libgl1 s390x 1.7.0-1build1 [142 kB] 145s Get:67 http://ftpmaster.internal/ubuntu questing/universe s390x libqt5network5t64 s390x 5.15.15+dfsg-4ubuntu1 [788 kB] 145s Get:68 http://ftpmaster.internal/ubuntu questing/main s390x libsm6 s390x 2:1.2.6-1 [18.3 kB] 145s Get:69 http://ftpmaster.internal/ubuntu questing/main s390x libxcb-icccm4 s390x 0.4.2-1 [11.4 kB] 145s Get:70 http://ftpmaster.internal/ubuntu questing/main s390x libxcb-util1 s390x 0.4.1-1 [10.7 kB] 145s Get:71 http://ftpmaster.internal/ubuntu questing/main s390x libxcb-image0 s390x 0.4.0-2build1 [12.0 kB] 145s Get:72 http://ftpmaster.internal/ubuntu questing/main s390x libxcb-keysyms1 s390x 0.4.1-1 [8908 B] 145s Get:73 http://ftpmaster.internal/ubuntu questing/main s390x libxcb-render0 s390x 1.17.0-2 [17.0 kB] 145s Get:74 http://ftpmaster.internal/ubuntu questing/main s390x libxcb-render-util0 s390x 0.3.10-1 [10.3 kB] 145s Get:75 http://ftpmaster.internal/ubuntu questing/main s390x libxcb-shape0 s390x 1.17.0-2 [6202 B] 145s Get:76 http://ftpmaster.internal/ubuntu questing/main s390x libxcb-xinerama0 s390x 1.17.0-2 [5430 B] 145s Get:77 http://ftpmaster.internal/ubuntu questing/main s390x libxcb-xinput0 s390x 1.17.0-2 [35.8 kB] 145s Get:78 http://ftpmaster.internal/ubuntu questing/main s390x libxcb-xkb1 s390x 1.17.0-2 [34.5 kB] 145s Get:79 http://ftpmaster.internal/ubuntu questing/main s390x libxkbcommon-x11-0 s390x 1.7.0-2 [14.8 kB] 145s Get:80 http://ftpmaster.internal/ubuntu questing/universe s390x libqt5gui5t64 s390x 5.15.15+dfsg-4ubuntu1 [4187 kB] 145s Get:81 http://ftpmaster.internal/ubuntu questing/universe s390x libqt5widgets5t64 s390x 5.15.15+dfsg-4ubuntu1 [2718 kB] 145s Get:82 http://ftpmaster.internal/ubuntu questing/universe s390x libqt5xml5t64 s390x 5.15.15+dfsg-4ubuntu1 [129 kB] 145s Get:83 http://ftpmaster.internal/ubuntu questing/universe s390x libqt5designer5 s390x 5.15.15-6build1 [2900 kB] 146s Get:84 http://ftpmaster.internal/ubuntu questing/universe s390x libqt5sql5t64 s390x 5.15.15+dfsg-4ubuntu1 [130 kB] 146s Get:85 http://ftpmaster.internal/ubuntu questing/universe s390x libqt5help5 s390x 5.15.15-6build1 [172 kB] 146s Get:86 http://ftpmaster.internal/ubuntu questing/universe s390x libqt5printsupport5t64 s390x 5.15.15+dfsg-4ubuntu1 [218 kB] 146s Get:87 http://ftpmaster.internal/ubuntu questing/universe s390x libqt5test5t64 s390x 5.15.15+dfsg-4ubuntu1 [156 kB] 146s Get:88 http://ftpmaster.internal/ubuntu questing/main s390x libraqm0 s390x 0.10.2-1 [15.8 kB] 146s Get:89 http://ftpmaster.internal/ubuntu questing/main s390x libsharpyuv0 s390x 1.5.0-0.1 [16.7 kB] 146s Get:90 http://ftpmaster.internal/ubuntu questing/main s390x libjbig0 s390x 2.1-6.1ubuntu2 [33.1 kB] 146s Get:91 http://ftpmaster.internal/ubuntu questing/main s390x libwebp7 s390x 1.5.0-0.1 [210 kB] 146s Get:92 http://ftpmaster.internal/ubuntu questing/main s390x libtiff6 s390x 4.7.0-3ubuntu1 [219 kB] 146s Get:93 http://ftpmaster.internal/ubuntu questing/main s390x libwebpdemux2 s390x 1.5.0-0.1 [12.6 kB] 146s Get:94 http://ftpmaster.internal/ubuntu questing/main s390x libwebpmux3 s390x 1.5.0-0.1 [25.8 kB] 146s Get:95 http://ftpmaster.internal/ubuntu questing/main s390x libxt6t64 s390x 1:1.2.1-1.2build1 [184 kB] 146s Get:96 http://ftpmaster.internal/ubuntu questing/main s390x libxmu6 s390x 2:1.1.3-3build2 [53.0 kB] 146s Get:97 http://ftpmaster.internal/ubuntu questing/main s390x libxpm4 s390x 1:3.5.17-1build2 [41.2 kB] 146s Get:98 http://ftpmaster.internal/ubuntu questing/main s390x libxaw7 s390x 2:1.0.16-1 [201 kB] 146s Get:99 http://ftpmaster.internal/ubuntu questing/main s390x libxfont2 s390x 1:2.0.6-1build1 [101 kB] 146s Get:100 http://ftpmaster.internal/ubuntu questing/main s390x libxkbfile1 s390x 1:1.1.0-1build4 [76.5 kB] 146s Get:101 http://ftpmaster.internal/ubuntu questing/main s390x libxrandr2 s390x 2:1.5.4-1 [20.8 kB] 146s Get:102 http://ftpmaster.internal/ubuntu questing/main s390x libxslt1.1 s390x 1.1.39-0exp1ubuntu4 [170 kB] 146s Get:103 http://ftpmaster.internal/ubuntu questing-proposed/universe s390x python-matplotlib-data all 3.10.1+dfsg1-3 [2936 kB] 147s Get:104 http://ftpmaster.internal/ubuntu questing/main s390x python3-all s390x 3.13.3-1 [882 B] 147s Get:105 http://ftpmaster.internal/ubuntu questing/universe s390x python3-async-generator all 1.10-4 [17.5 kB] 147s Get:106 http://ftpmaster.internal/ubuntu questing/universe s390x python3-bottleneck s390x 1.4.2+ds1-2build1 [110 kB] 147s Get:107 http://ftpmaster.internal/ubuntu questing/universe s390x python3-brotli s390x 1.1.0-2build4 [380 kB] 147s Get:108 http://ftpmaster.internal/ubuntu questing/main s390x python3-soupsieve all 2.7-1 [33.5 kB] 147s Get:109 http://ftpmaster.internal/ubuntu questing/main s390x python3-bs4 all 4.13.4-1 [137 kB] 147s Get:110 http://ftpmaster.internal/ubuntu questing/main s390x python3-click all 8.2.0+0.really.8.1.8-1 [80.0 kB] 147s Get:111 http://ftpmaster.internal/ubuntu questing/universe s390x python3-cloudpickle all 3.1.1-1 [22.4 kB] 147s Get:112 http://ftpmaster.internal/ubuntu questing/universe s390x python3-contourpy s390x 1.3.1-1build1 [197 kB] 147s Get:113 http://ftpmaster.internal/ubuntu questing/universe s390x python3-cycler all 0.12.1-1 [9716 B] 147s Get:114 http://ftpmaster.internal/ubuntu questing/universe s390x python3-fsspec all 2025.3.0-1 [216 kB] 147s Get:115 http://ftpmaster.internal/ubuntu questing/universe s390x python3-toolz all 1.0.0-2 [45.0 kB] 147s Get:116 http://ftpmaster.internal/ubuntu questing/main s390x python3-packaging all 25.0-1 [52.8 kB] 147s Get:117 http://ftpmaster.internal/ubuntu questing/universe s390x python3-locket all 1.0.0-2 [5872 B] 147s Get:118 http://ftpmaster.internal/ubuntu questing/universe s390x python3-partd all 1.4.2-1 [15.7 kB] 147s Get:119 http://ftpmaster.internal/ubuntu questing/universe s390x python3-dask all 2024.12.1+dfsg-2 [875 kB] 147s Get:120 http://ftpmaster.internal/ubuntu questing/main s390x python3-decorator all 5.2.1-2 [28.1 kB] 147s Get:121 http://ftpmaster.internal/ubuntu questing/main s390x python3-defusedxml all 0.7.1-3 [42.2 kB] 147s Get:122 http://ftpmaster.internal/ubuntu questing/universe s390x python3-et-xmlfile all 2.0.0-1 [79.4 kB] 147s Get:123 http://ftpmaster.internal/ubuntu questing/universe s390x python3-execnet all 2.1.1-1 [33.4 kB] 147s Get:124 http://ftpmaster.internal/ubuntu questing/main s390x python3-platformdirs all 4.3.7-1 [16.9 kB] 147s Get:125 http://ftpmaster.internal/ubuntu questing/universe s390x python3-fs all 2.4.16-7 [90.8 kB] 147s Get:126 http://ftpmaster.internal/ubuntu questing/main s390x python3-lxml s390x 5.4.0-1 [1367 kB] 147s Get:127 http://ftpmaster.internal/ubuntu questing/universe s390x python3-lz4 s390x 4.4.0+dfsg-2 [26.6 kB] 147s Get:128 http://ftpmaster.internal/ubuntu questing/universe s390x python3-scipy s390x 1.14.1-4ubuntu2 [18.0 MB] 148s Get:129 http://ftpmaster.internal/ubuntu questing/universe s390x python3-mpmath all 1.3.0-1 [425 kB] 148s Get:130 http://ftpmaster.internal/ubuntu questing/universe s390x python3-sympy all 1.13.3-5 [4229 kB] 148s Get:131 http://ftpmaster.internal/ubuntu questing/universe s390x python3-ufolib2 all 0.17.1+dfsg1-1 [33.5 kB] 148s Get:132 http://ftpmaster.internal/ubuntu questing/universe s390x unicode-data all 15.1.0-1 [8878 kB] 148s Get:133 http://ftpmaster.internal/ubuntu questing/universe s390x python3-fonttools s390x 4.55.3-2build1 [1496 kB] 149s Get:134 http://ftpmaster.internal/ubuntu questing/main s390x python3-webencodings all 0.5.1-5 [11.5 kB] 149s Get:135 http://ftpmaster.internal/ubuntu questing/main s390x python3-html5lib all 1.2-2 [90.6 kB] 149s Get:136 http://ftpmaster.internal/ubuntu questing/main s390x python3-sortedcontainers all 2.4.0-2 [27.6 kB] 149s Get:137 http://ftpmaster.internal/ubuntu questing/universe s390x python3-hypothesis all 6.127.4-1 [335 kB] 149s Get:138 http://ftpmaster.internal/ubuntu questing/universe s390x python3-iniconfig all 1.1.1-2 [6024 B] 149s Get:139 http://ftpmaster.internal/ubuntu questing/universe s390x python3-kiwisolver s390x 1.4.7-3build1 [55.0 kB] 149s Get:140 http://ftpmaster.internal/ubuntu questing/main s390x libopenjp2-7 s390x 2.5.3-2 [207 kB] 149s Get:141 http://ftpmaster.internal/ubuntu questing/main s390x python3-pil s390x 11.1.0-5build1 [498 kB] 149s Get:142 http://ftpmaster.internal/ubuntu questing/main s390x python3.13-tk s390x 3.13.3-1 [108 kB] 149s Get:143 http://ftpmaster.internal/ubuntu questing/main s390x python3-tk s390x 3.13.3-1 [9854 B] 149s Get:144 http://ftpmaster.internal/ubuntu questing/universe s390x python3-pil.imagetk s390x 11.1.0-5build1 [9668 B] 149s Get:145 http://ftpmaster.internal/ubuntu questing-proposed/universe s390x python3-matplotlib s390x 3.10.1+dfsg1-3 [18.0 MB] 149s Get:146 http://ftpmaster.internal/ubuntu questing/universe s390x python3-numexpr s390x 2.10.2-1build2 [142 kB] 149s Get:147 http://ftpmaster.internal/ubuntu questing/universe s390x python3-odf all 1.4.2-4 [79.0 kB] 149s Get:148 http://ftpmaster.internal/ubuntu questing/universe s390x python3-openpyxl all 3.1.5+dfsg-2 [152 kB] 150s Get:149 http://ftpmaster.internal/ubuntu questing/universe s390x python3-pluggy all 1.5.0-1 [21.0 kB] 150s Get:150 http://ftpmaster.internal/ubuntu questing/universe s390x python3-py all 1.11.0-4 [72.7 kB] 150s Get:151 http://ftpmaster.internal/ubuntu questing/universe s390x python3-pyqt5.sip s390x 12.17.0-1build1 [66.5 kB] 150s Get:152 http://ftpmaster.internal/ubuntu questing/universe s390x python3-pyqt5 s390x 5.15.11+dfsg-2 [2880 kB] 150s Get:153 http://ftpmaster.internal/ubuntu questing/universe s390x python3-pyreadstat s390x 1.2.8-1build1 [388 kB] 150s Get:154 http://ftpmaster.internal/ubuntu questing/universe s390x python3-pytest all 8.3.5-1 [252 kB] 150s Get:155 http://ftpmaster.internal/ubuntu questing/universe s390x python3-pytest-asyncio all 0.25.1-1 [17.0 kB] 150s Get:156 http://ftpmaster.internal/ubuntu questing/universe s390x python3-pytest-forked all 1.6.0-3 [7470 B] 150s Get:157 http://ftpmaster.internal/ubuntu questing/main s390x python3-werkzeug all 3.1.3-2 [169 kB] 150s Get:158 http://ftpmaster.internal/ubuntu questing/universe s390x python3-pytest-localserver all 0.9.0.post0-1 [21.9 kB] 150s Get:159 http://ftpmaster.internal/ubuntu questing/universe s390x python3-pytest-xdist all 3.6.1-1 [33.8 kB] 150s Get:160 http://ftpmaster.internal/ubuntu questing/universe s390x python3-pytestqt all 4.4.0-1 [32.4 kB] 150s Get:161 http://ftpmaster.internal/ubuntu questing/main s390x python3-greenlet s390x 3.1.0-1build1 [162 kB] 150s Get:162 http://ftpmaster.internal/ubuntu questing/main s390x python3-sqlalchemy all 2.0.38+ds1-0ubuntu2 [1215 kB] 150s Get:163 http://ftpmaster.internal/ubuntu questing/main s390x python3-tabulate all 0.9.0-1 [45.3 kB] 150s Get:164 http://ftpmaster.internal/ubuntu questing/main s390x python3-tz all 2025.1-3 [1866 B] 150s Get:165 http://ftpmaster.internal/ubuntu questing-proposed/universe s390x python3-xarray all 2025.03.1-8 [831 kB] 150s Get:166 http://ftpmaster.internal/ubuntu questing/universe s390x python3-xlrd all 2.0.1-2 [83.1 kB] 150s Get:167 http://ftpmaster.internal/ubuntu questing/universe s390x python3-xlsxwriter all 3.1.9-2 [462 kB] 150s Get:168 http://ftpmaster.internal/ubuntu questing/universe s390x python3-zstandard s390x 0.23.0-3build1 [407 kB] 150s Get:169 http://ftpmaster.internal/ubuntu questing/main s390x tzdata-legacy all 2025b-1ubuntu1 [99.2 kB] 150s Get:170 http://ftpmaster.internal/ubuntu questing/main s390x x11-xkb-utils s390x 7.7+9 [169 kB] 150s Get:171 http://ftpmaster.internal/ubuntu questing/universe s390x xsel s390x 1.2.1-1 [21.1 kB] 150s Get:172 http://ftpmaster.internal/ubuntu questing/main s390x xserver-common all 2:21.1.16-1ubuntu1 [34.4 kB] 150s Get:173 http://ftpmaster.internal/ubuntu questing/universe s390x xvfb s390x 2:21.1.16-1ubuntu1 [942 kB] 150s Get:174 http://ftpmaster.internal/ubuntu questing/universe s390x locales-all s390x 2.41-6ubuntu1 [11.5 MB] 151s Fetched 112 MB in 8s (13.6 MB/s) 151s Selecting previously unselected package libtcl8.6:s390x. 151s (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 ... 84787 files and directories currently installed.) 151s Preparing to unpack .../000-libtcl8.6_8.6.16+dfsg-1_s390x.deb ... 151s Unpacking libtcl8.6:s390x (8.6.16+dfsg-1) ... 151s Selecting previously unselected package libfreetype6:s390x. 151s Preparing to unpack .../001-libfreetype6_2.13.3+dfsg-1_s390x.deb ... 151s Unpacking libfreetype6:s390x (2.13.3+dfsg-1) ... 151s Selecting previously unselected package fonts-dejavu-mono. 151s Preparing to unpack .../002-fonts-dejavu-mono_2.37-8_all.deb ... 151s Unpacking fonts-dejavu-mono (2.37-8) ... 151s Selecting previously unselected package fonts-dejavu-core. 151s Preparing to unpack .../003-fonts-dejavu-core_2.37-8_all.deb ... 151s Unpacking fonts-dejavu-core (2.37-8) ... 151s Selecting previously unselected package fontconfig-config. 151s Preparing to unpack .../004-fontconfig-config_2.15.0-2.2ubuntu1_s390x.deb ... 151s Unpacking fontconfig-config (2.15.0-2.2ubuntu1) ... 151s Selecting previously unselected package libfontconfig1:s390x. 151s Preparing to unpack .../005-libfontconfig1_2.15.0-2.2ubuntu1_s390x.deb ... 151s Unpacking libfontconfig1:s390x (2.15.0-2.2ubuntu1) ... 151s Selecting previously unselected package libxrender1:s390x. 151s Preparing to unpack .../006-libxrender1_1%3a0.9.12-1_s390x.deb ... 151s Unpacking libxrender1:s390x (1:0.9.12-1) ... 151s Selecting previously unselected package libxft2:s390x. 151s Preparing to unpack .../007-libxft2_2.3.6-1build1_s390x.deb ... 151s Unpacking libxft2:s390x (2.3.6-1build1) ... 151s Selecting previously unselected package x11-common. 151s Preparing to unpack .../008-x11-common_1%3a7.7+23ubuntu4_all.deb ... 151s Unpacking x11-common (1:7.7+23ubuntu4) ... 151s Selecting previously unselected package libxss1:s390x. 151s Preparing to unpack .../009-libxss1_1%3a1.2.3-1build3_s390x.deb ... 151s Unpacking libxss1:s390x (1:1.2.3-1build3) ... 151s Selecting previously unselected package libtk8.6:s390x. 151s Preparing to unpack .../010-libtk8.6_8.6.16-1_s390x.deb ... 151s Unpacking libtk8.6:s390x (8.6.16-1) ... 151s Selecting previously unselected package tk8.6-blt2.5. 151s Preparing to unpack .../011-tk8.6-blt2.5_2.5.3+dfsg-8_s390x.deb ... 151s Unpacking tk8.6-blt2.5 (2.5.3+dfsg-8) ... 151s Selecting previously unselected package blt. 151s Preparing to unpack .../012-blt_2.5.3+dfsg-8_s390x.deb ... 151s Unpacking blt (2.5.3+dfsg-8) ... 151s Selecting previously unselected package fontconfig. 151s Preparing to unpack .../013-fontconfig_2.15.0-2.2ubuntu1_s390x.deb ... 151s Unpacking fontconfig (2.15.0-2.2ubuntu1) ... 151s Selecting previously unselected package fonts-lyx. 151s Preparing to unpack .../014-fonts-lyx_2.4.3-1_all.deb ... 151s Unpacking fonts-lyx (2.4.3-1) ... 151s Selecting previously unselected package libavahi-common-data:s390x. 151s Preparing to unpack .../015-libavahi-common-data_0.8-16ubuntu2_s390x.deb ... 151s Unpacking libavahi-common-data:s390x (0.8-16ubuntu2) ... 151s Selecting previously unselected package libavahi-common3:s390x. 151s Preparing to unpack .../016-libavahi-common3_0.8-16ubuntu2_s390x.deb ... 151s Unpacking libavahi-common3:s390x (0.8-16ubuntu2) ... 151s Selecting previously unselected package libavahi-client3:s390x. 151s Preparing to unpack .../017-libavahi-client3_0.8-16ubuntu2_s390x.deb ... 151s Unpacking libavahi-client3:s390x (0.8-16ubuntu2) ... 151s Selecting previously unselected package libcups2t64:s390x. 151s Preparing to unpack .../018-libcups2t64_2.4.12-0ubuntu1_s390x.deb ... 151s Unpacking libcups2t64:s390x (2.4.12-0ubuntu1) ... 151s Selecting previously unselected package libdeflate0:s390x. 151s Preparing to unpack .../019-libdeflate0_1.23-2_s390x.deb ... 151s Unpacking libdeflate0:s390x (1.23-2) ... 151s Selecting previously unselected package libdouble-conversion3:s390x. 151s Preparing to unpack .../020-libdouble-conversion3_3.3.1-1_s390x.deb ... 151s Unpacking libdouble-conversion3:s390x (3.3.1-1) ... 151s Selecting previously unselected package libwayland-server0:s390x. 151s Preparing to unpack .../021-libwayland-server0_1.23.1-3_s390x.deb ... 151s Unpacking libwayland-server0:s390x (1.23.1-3) ... 151s Selecting previously unselected package libx11-xcb1:s390x. 151s Preparing to unpack .../022-libx11-xcb1_2%3a1.8.12-1_s390x.deb ... 151s Unpacking libx11-xcb1:s390x (2:1.8.12-1) ... 151s Selecting previously unselected package libxcb-dri3-0:s390x. 151s Preparing to unpack .../023-libxcb-dri3-0_1.17.0-2_s390x.deb ... 151s Unpacking libxcb-dri3-0:s390x (1.17.0-2) ... 151s Selecting previously unselected package libxcb-present0:s390x. 151s Preparing to unpack .../024-libxcb-present0_1.17.0-2_s390x.deb ... 151s Unpacking libxcb-present0:s390x (1.17.0-2) ... 151s Selecting previously unselected package libxcb-randr0:s390x. 151s Preparing to unpack .../025-libxcb-randr0_1.17.0-2_s390x.deb ... 151s Unpacking libxcb-randr0:s390x (1.17.0-2) ... 151s Selecting previously unselected package libxcb-sync1:s390x. 151s Preparing to unpack .../026-libxcb-sync1_1.17.0-2_s390x.deb ... 151s Unpacking libxcb-sync1:s390x (1.17.0-2) ... 152s Selecting previously unselected package libxcb-xfixes0:s390x. 152s Preparing to unpack .../027-libxcb-xfixes0_1.17.0-2_s390x.deb ... 152s Unpacking libxcb-xfixes0:s390x (1.17.0-2) ... 152s Selecting previously unselected package libxshmfence1:s390x. 152s Preparing to unpack .../028-libxshmfence1_1.3.3-1_s390x.deb ... 152s Unpacking libxshmfence1:s390x (1.3.3-1) ... 152s Selecting previously unselected package mesa-libgallium:s390x. 152s Preparing to unpack .../029-mesa-libgallium_25.0.3-1ubuntu2_s390x.deb ... 152s Unpacking mesa-libgallium:s390x (25.0.3-1ubuntu2) ... 152s Selecting previously unselected package libgbm1:s390x. 152s Preparing to unpack .../030-libgbm1_25.0.3-1ubuntu2_s390x.deb ... 152s Unpacking libgbm1:s390x (25.0.3-1ubuntu2) ... 152s Selecting previously unselected package libwayland-client0:s390x. 152s Preparing to unpack .../031-libwayland-client0_1.23.1-3_s390x.deb ... 152s Unpacking libwayland-client0:s390x (1.23.1-3) ... 152s Selecting previously unselected package libxcb-shm0:s390x. 152s Preparing to unpack .../032-libxcb-shm0_1.17.0-2_s390x.deb ... 152s Unpacking libxcb-shm0:s390x (1.17.0-2) ... 152s Selecting previously unselected package libegl-mesa0:s390x. 152s Preparing to unpack .../033-libegl-mesa0_25.0.3-1ubuntu2_s390x.deb ... 152s Unpacking libegl-mesa0:s390x (25.0.3-1ubuntu2) ... 152s Selecting previously unselected package libfontenc1:s390x. 152s Preparing to unpack .../034-libfontenc1_1%3a1.1.8-1build1_s390x.deb ... 152s Unpacking libfontenc1:s390x (1:1.1.8-1build1) ... 152s Selecting previously unselected package libvulkan1:s390x. 152s Preparing to unpack .../035-libvulkan1_1.4.309.0-1_s390x.deb ... 152s Unpacking libvulkan1:s390x (1.4.309.0-1) ... 152s Selecting previously unselected package libgl1-mesa-dri:s390x. 152s Preparing to unpack .../036-libgl1-mesa-dri_25.0.3-1ubuntu2_s390x.deb ... 152s Unpacking libgl1-mesa-dri:s390x (25.0.3-1ubuntu2) ... 152s Selecting previously unselected package libxcb-glx0:s390x. 152s Preparing to unpack .../037-libxcb-glx0_1.17.0-2_s390x.deb ... 152s Unpacking libxcb-glx0:s390x (1.17.0-2) ... 152s Selecting previously unselected package libxxf86vm1:s390x. 152s Preparing to unpack .../038-libxxf86vm1_1%3a1.1.4-1build4_s390x.deb ... 152s Unpacking libxxf86vm1:s390x (1:1.1.4-1build4) ... 152s Selecting previously unselected package libglx-mesa0:s390x. 152s Preparing to unpack .../039-libglx-mesa0_25.0.3-1ubuntu2_s390x.deb ... 152s Unpacking libglx-mesa0:s390x (25.0.3-1ubuntu2) ... 152s Selecting previously unselected package libgomp1:s390x. 152s Preparing to unpack .../040-libgomp1_15.1.0-2ubuntu1_s390x.deb ... 152s Unpacking libgomp1:s390x (15.1.0-2ubuntu1) ... 152s Selecting previously unselected package libgraphite2-3:s390x. 152s Preparing to unpack .../041-libgraphite2-3_1.3.14-2ubuntu1_s390x.deb ... 152s Unpacking libgraphite2-3:s390x (1.3.14-2ubuntu1) ... 152s Selecting previously unselected package libharfbuzz0b:s390x. 152s Preparing to unpack .../042-libharfbuzz0b_10.2.0-1_s390x.deb ... 152s Unpacking libharfbuzz0b:s390x (10.2.0-1) ... 152s Selecting previously unselected package libice6:s390x. 152s Preparing to unpack .../043-libice6_2%3a1.1.1-1_s390x.deb ... 152s Unpacking libice6:s390x (2:1.1.1-1) ... 152s Selecting previously unselected package libimagequant0:s390x. 152s Preparing to unpack .../044-libimagequant0_2.18.0-1build1_s390x.deb ... 152s Unpacking libimagequant0:s390x (2.18.0-1build1) ... 152s Selecting previously unselected package libwacom-common. 152s Preparing to unpack .../045-libwacom-common_2.14.0-1_all.deb ... 152s Unpacking libwacom-common (2.14.0-1) ... 152s Selecting previously unselected package libwacom9:s390x. 152s Preparing to unpack .../046-libwacom9_2.14.0-1_s390x.deb ... 152s Unpacking libwacom9:s390x (2.14.0-1) ... 152s Selecting previously unselected package libinput-bin. 152s Preparing to unpack .../047-libinput-bin_1.28.1-1_s390x.deb ... 152s Unpacking libinput-bin (1.28.1-1) ... 152s Selecting previously unselected package libmtdev1t64:s390x. 152s Preparing to unpack .../048-libmtdev1t64_1.1.7-1_s390x.deb ... 152s Unpacking libmtdev1t64:s390x (1.1.7-1) ... 152s Selecting previously unselected package libinput10:s390x. 152s Preparing to unpack .../049-libinput10_1.28.1-1_s390x.deb ... 152s Unpacking libinput10:s390x (1.28.1-1) ... 152s Selecting previously unselected package libjpeg-turbo8:s390x. 152s Preparing to unpack .../050-libjpeg-turbo8_2.1.5-3ubuntu2_s390x.deb ... 152s Unpacking libjpeg-turbo8:s390x (2.1.5-3ubuntu2) ... 152s Selecting previously unselected package libjpeg8:s390x. 152s Preparing to unpack .../051-libjpeg8_8c-2ubuntu11_s390x.deb ... 152s Unpacking libjpeg8:s390x (8c-2ubuntu11) ... 152s Selecting previously unselected package libjs-jquery. 152s Preparing to unpack .../052-libjs-jquery_3.6.1+dfsg+~3.5.14-1_all.deb ... 152s Unpacking libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 152s Selecting previously unselected package libjs-jquery-ui. 152s Preparing to unpack .../053-libjs-jquery-ui_1.13.2+dfsg-1_all.deb ... 152s Unpacking libjs-jquery-ui (1.13.2+dfsg-1) ... 152s Selecting previously unselected package liblbfgsb0:s390x. 152s Preparing to unpack .../054-liblbfgsb0_3.0+dfsg.4-1build1_s390x.deb ... 152s Unpacking liblbfgsb0:s390x (3.0+dfsg.4-1build1) ... 152s Selecting previously unselected package liblcms2-2:s390x. 152s Preparing to unpack .../055-liblcms2-2_2.16-2_s390x.deb ... 152s Unpacking liblcms2-2:s390x (2.16-2) ... 152s Selecting previously unselected package libmd4c0:s390x. 152s Preparing to unpack .../056-libmd4c0_0.5.2-2_s390x.deb ... 152s Unpacking libmd4c0:s390x (0.5.2-2) ... 152s Selecting previously unselected package libpcre2-16-0:s390x. 152s Preparing to unpack .../057-libpcre2-16-0_10.45-1_s390x.deb ... 152s Unpacking libpcre2-16-0:s390x (10.45-1) ... 152s Selecting previously unselected package libpixman-1-0:s390x. 152s Preparing to unpack .../058-libpixman-1-0_0.44.0-3_s390x.deb ... 152s Unpacking libpixman-1-0:s390x (0.44.0-3) ... 152s Selecting previously unselected package libqhull-r8.0:s390x. 152s Preparing to unpack .../059-libqhull-r8.0_2020.2-6build1_s390x.deb ... 152s Unpacking libqhull-r8.0:s390x (2020.2-6build1) ... 152s Selecting previously unselected package libqt5core5t64:s390x. 152s Preparing to unpack .../060-libqt5core5t64_5.15.15+dfsg-4ubuntu1_s390x.deb ... 152s Unpacking libqt5core5t64:s390x (5.15.15+dfsg-4ubuntu1) ... 152s Selecting previously unselected package libqt5dbus5t64:s390x. 152s Preparing to unpack .../061-libqt5dbus5t64_5.15.15+dfsg-4ubuntu1_s390x.deb ... 152s Unpacking libqt5dbus5t64:s390x (5.15.15+dfsg-4ubuntu1) ... 152s Selecting previously unselected package libglvnd0:s390x. 152s Preparing to unpack .../062-libglvnd0_1.7.0-1build1_s390x.deb ... 152s Unpacking libglvnd0:s390x (1.7.0-1build1) ... 152s Selecting previously unselected package libegl1:s390x. 152s Preparing to unpack .../063-libegl1_1.7.0-1build1_s390x.deb ... 152s Unpacking libegl1:s390x (1.7.0-1build1) ... 152s Selecting previously unselected package libglx0:s390x. 152s Preparing to unpack .../064-libglx0_1.7.0-1build1_s390x.deb ... 152s Unpacking libglx0:s390x (1.7.0-1build1) ... 152s Selecting previously unselected package libgl1:s390x. 152s Preparing to unpack .../065-libgl1_1.7.0-1build1_s390x.deb ... 152s Unpacking libgl1:s390x (1.7.0-1build1) ... 152s Selecting previously unselected package libqt5network5t64:s390x. 152s Preparing to unpack .../066-libqt5network5t64_5.15.15+dfsg-4ubuntu1_s390x.deb ... 152s Unpacking libqt5network5t64:s390x (5.15.15+dfsg-4ubuntu1) ... 152s Selecting previously unselected package libsm6:s390x. 152s Preparing to unpack .../067-libsm6_2%3a1.2.6-1_s390x.deb ... 152s Unpacking libsm6:s390x (2:1.2.6-1) ... 152s Selecting previously unselected package libxcb-icccm4:s390x. 152s Preparing to unpack .../068-libxcb-icccm4_0.4.2-1_s390x.deb ... 152s Unpacking libxcb-icccm4:s390x (0.4.2-1) ... 152s Selecting previously unselected package libxcb-util1:s390x. 152s Preparing to unpack .../069-libxcb-util1_0.4.1-1_s390x.deb ... 152s Unpacking libxcb-util1:s390x (0.4.1-1) ... 152s Selecting previously unselected package libxcb-image0:s390x. 152s Preparing to unpack .../070-libxcb-image0_0.4.0-2build1_s390x.deb ... 152s Unpacking libxcb-image0:s390x (0.4.0-2build1) ... 152s Selecting previously unselected package libxcb-keysyms1:s390x. 152s Preparing to unpack .../071-libxcb-keysyms1_0.4.1-1_s390x.deb ... 152s Unpacking libxcb-keysyms1:s390x (0.4.1-1) ... 152s Selecting previously unselected package libxcb-render0:s390x. 152s Preparing to unpack .../072-libxcb-render0_1.17.0-2_s390x.deb ... 152s Unpacking libxcb-render0:s390x (1.17.0-2) ... 152s Selecting previously unselected package libxcb-render-util0:s390x. 152s Preparing to unpack .../073-libxcb-render-util0_0.3.10-1_s390x.deb ... 152s Unpacking libxcb-render-util0:s390x (0.3.10-1) ... 152s Selecting previously unselected package libxcb-shape0:s390x. 152s Preparing to unpack .../074-libxcb-shape0_1.17.0-2_s390x.deb ... 152s Unpacking libxcb-shape0:s390x (1.17.0-2) ... 152s Selecting previously unselected package libxcb-xinerama0:s390x. 152s Preparing to unpack .../075-libxcb-xinerama0_1.17.0-2_s390x.deb ... 152s Unpacking libxcb-xinerama0:s390x (1.17.0-2) ... 152s Selecting previously unselected package libxcb-xinput0:s390x. 152s Preparing to unpack .../076-libxcb-xinput0_1.17.0-2_s390x.deb ... 152s Unpacking libxcb-xinput0:s390x (1.17.0-2) ... 152s Selecting previously unselected package libxcb-xkb1:s390x. 152s Preparing to unpack .../077-libxcb-xkb1_1.17.0-2_s390x.deb ... 152s Unpacking libxcb-xkb1:s390x (1.17.0-2) ... 152s Selecting previously unselected package libxkbcommon-x11-0:s390x. 152s Preparing to unpack .../078-libxkbcommon-x11-0_1.7.0-2_s390x.deb ... 152s Unpacking libxkbcommon-x11-0:s390x (1.7.0-2) ... 152s Selecting previously unselected package libqt5gui5t64:s390x. 152s Preparing to unpack .../079-libqt5gui5t64_5.15.15+dfsg-4ubuntu1_s390x.deb ... 152s Unpacking libqt5gui5t64:s390x (5.15.15+dfsg-4ubuntu1) ... 152s Selecting previously unselected package libqt5widgets5t64:s390x. 152s Preparing to unpack .../080-libqt5widgets5t64_5.15.15+dfsg-4ubuntu1_s390x.deb ... 152s Unpacking libqt5widgets5t64:s390x (5.15.15+dfsg-4ubuntu1) ... 152s Selecting previously unselected package libqt5xml5t64:s390x. 152s Preparing to unpack .../081-libqt5xml5t64_5.15.15+dfsg-4ubuntu1_s390x.deb ... 152s Unpacking libqt5xml5t64:s390x (5.15.15+dfsg-4ubuntu1) ... 152s Selecting previously unselected package libqt5designer5:s390x. 152s Preparing to unpack .../082-libqt5designer5_5.15.15-6build1_s390x.deb ... 152s Unpacking libqt5designer5:s390x (5.15.15-6build1) ... 152s Selecting previously unselected package libqt5sql5t64:s390x. 152s Preparing to unpack .../083-libqt5sql5t64_5.15.15+dfsg-4ubuntu1_s390x.deb ... 152s Unpacking libqt5sql5t64:s390x (5.15.15+dfsg-4ubuntu1) ... 152s Selecting previously unselected package libqt5help5:s390x. 152s Preparing to unpack .../084-libqt5help5_5.15.15-6build1_s390x.deb ... 152s Unpacking libqt5help5:s390x (5.15.15-6build1) ... 152s Selecting previously unselected package libqt5printsupport5t64:s390x. 152s Preparing to unpack .../085-libqt5printsupport5t64_5.15.15+dfsg-4ubuntu1_s390x.deb ... 152s Unpacking libqt5printsupport5t64:s390x (5.15.15+dfsg-4ubuntu1) ... 152s Selecting previously unselected package libqt5test5t64:s390x. 152s Preparing to unpack .../086-libqt5test5t64_5.15.15+dfsg-4ubuntu1_s390x.deb ... 152s Unpacking libqt5test5t64:s390x (5.15.15+dfsg-4ubuntu1) ... 153s Selecting previously unselected package libraqm0:s390x. 153s Preparing to unpack .../087-libraqm0_0.10.2-1_s390x.deb ... 153s Unpacking libraqm0:s390x (0.10.2-1) ... 153s Selecting previously unselected package libsharpyuv0:s390x. 153s Preparing to unpack .../088-libsharpyuv0_1.5.0-0.1_s390x.deb ... 153s Unpacking libsharpyuv0:s390x (1.5.0-0.1) ... 153s Selecting previously unselected package libjbig0:s390x. 153s Preparing to unpack .../089-libjbig0_2.1-6.1ubuntu2_s390x.deb ... 153s Unpacking libjbig0:s390x (2.1-6.1ubuntu2) ... 153s Selecting previously unselected package libwebp7:s390x. 153s Preparing to unpack .../090-libwebp7_1.5.0-0.1_s390x.deb ... 153s Unpacking libwebp7:s390x (1.5.0-0.1) ... 153s Selecting previously unselected package libtiff6:s390x. 153s Preparing to unpack .../091-libtiff6_4.7.0-3ubuntu1_s390x.deb ... 153s Unpacking libtiff6:s390x (4.7.0-3ubuntu1) ... 153s Selecting previously unselected package libwebpdemux2:s390x. 153s Preparing to unpack .../092-libwebpdemux2_1.5.0-0.1_s390x.deb ... 153s Unpacking libwebpdemux2:s390x (1.5.0-0.1) ... 153s Selecting previously unselected package libwebpmux3:s390x. 153s Preparing to unpack .../093-libwebpmux3_1.5.0-0.1_s390x.deb ... 153s Unpacking libwebpmux3:s390x (1.5.0-0.1) ... 153s Selecting previously unselected package libxt6t64:s390x. 153s Preparing to unpack .../094-libxt6t64_1%3a1.2.1-1.2build1_s390x.deb ... 153s Unpacking libxt6t64:s390x (1:1.2.1-1.2build1) ... 153s Selecting previously unselected package libxmu6:s390x. 153s Preparing to unpack .../095-libxmu6_2%3a1.1.3-3build2_s390x.deb ... 153s Unpacking libxmu6:s390x (2:1.1.3-3build2) ... 153s Selecting previously unselected package libxpm4:s390x. 153s Preparing to unpack .../096-libxpm4_1%3a3.5.17-1build2_s390x.deb ... 153s Unpacking libxpm4:s390x (1:3.5.17-1build2) ... 153s Selecting previously unselected package libxaw7:s390x. 153s Preparing to unpack .../097-libxaw7_2%3a1.0.16-1_s390x.deb ... 153s Unpacking libxaw7:s390x (2:1.0.16-1) ... 153s Selecting previously unselected package libxfont2:s390x. 153s Preparing to unpack .../098-libxfont2_1%3a2.0.6-1build1_s390x.deb ... 153s Unpacking libxfont2:s390x (1:2.0.6-1build1) ... 153s Selecting previously unselected package libxkbfile1:s390x. 153s Preparing to unpack .../099-libxkbfile1_1%3a1.1.0-1build4_s390x.deb ... 153s Unpacking libxkbfile1:s390x (1:1.1.0-1build4) ... 153s Selecting previously unselected package libxrandr2:s390x. 153s Preparing to unpack .../100-libxrandr2_2%3a1.5.4-1_s390x.deb ... 153s Unpacking libxrandr2:s390x (2:1.5.4-1) ... 153s Selecting previously unselected package libxslt1.1:s390x. 153s Preparing to unpack .../101-libxslt1.1_1.1.39-0exp1ubuntu4_s390x.deb ... 153s Unpacking libxslt1.1:s390x (1.1.39-0exp1ubuntu4) ... 153s Selecting previously unselected package python-matplotlib-data. 153s Preparing to unpack .../102-python-matplotlib-data_3.10.1+dfsg1-3_all.deb ... 153s Unpacking python-matplotlib-data (3.10.1+dfsg1-3) ... 153s Selecting previously unselected package python3-all. 153s Preparing to unpack .../103-python3-all_3.13.3-1_s390x.deb ... 153s Unpacking python3-all (3.13.3-1) ... 153s Selecting previously unselected package python3-async-generator. 153s Preparing to unpack .../104-python3-async-generator_1.10-4_all.deb ... 153s Unpacking python3-async-generator (1.10-4) ... 153s Selecting previously unselected package python3-bottleneck. 153s Preparing to unpack .../105-python3-bottleneck_1.4.2+ds1-2build1_s390x.deb ... 153s Unpacking python3-bottleneck (1.4.2+ds1-2build1) ... 153s Selecting previously unselected package python3-brotli. 153s Preparing to unpack .../106-python3-brotli_1.1.0-2build4_s390x.deb ... 153s Unpacking python3-brotli (1.1.0-2build4) ... 153s Selecting previously unselected package python3-soupsieve. 153s Preparing to unpack .../107-python3-soupsieve_2.7-1_all.deb ... 153s Unpacking python3-soupsieve (2.7-1) ... 153s Selecting previously unselected package python3-bs4. 153s Preparing to unpack .../108-python3-bs4_4.13.4-1_all.deb ... 153s Unpacking python3-bs4 (4.13.4-1) ... 153s Selecting previously unselected package python3-click. 153s Preparing to unpack .../109-python3-click_8.2.0+0.really.8.1.8-1_all.deb ... 153s Unpacking python3-click (8.2.0+0.really.8.1.8-1) ... 153s Selecting previously unselected package python3-cloudpickle. 153s Preparing to unpack .../110-python3-cloudpickle_3.1.1-1_all.deb ... 153s Unpacking python3-cloudpickle (3.1.1-1) ... 153s Selecting previously unselected package python3-contourpy. 153s Preparing to unpack .../111-python3-contourpy_1.3.1-1build1_s390x.deb ... 153s Unpacking python3-contourpy (1.3.1-1build1) ... 153s Selecting previously unselected package python3-cycler. 153s Preparing to unpack .../112-python3-cycler_0.12.1-1_all.deb ... 153s Unpacking python3-cycler (0.12.1-1) ... 153s Selecting previously unselected package python3-fsspec. 153s Preparing to unpack .../113-python3-fsspec_2025.3.0-1_all.deb ... 153s Unpacking python3-fsspec (2025.3.0-1) ... 153s Selecting previously unselected package python3-toolz. 153s Preparing to unpack .../114-python3-toolz_1.0.0-2_all.deb ... 153s Unpacking python3-toolz (1.0.0-2) ... 153s Selecting previously unselected package python3-packaging. 153s Preparing to unpack .../115-python3-packaging_25.0-1_all.deb ... 153s Unpacking python3-packaging (25.0-1) ... 153s Selecting previously unselected package python3-locket. 153s Preparing to unpack .../116-python3-locket_1.0.0-2_all.deb ... 153s Unpacking python3-locket (1.0.0-2) ... 153s Selecting previously unselected package python3-partd. 153s Preparing to unpack .../117-python3-partd_1.4.2-1_all.deb ... 153s Unpacking python3-partd (1.4.2-1) ... 153s Selecting previously unselected package python3-dask. 153s Preparing to unpack .../118-python3-dask_2024.12.1+dfsg-2_all.deb ... 153s Unpacking python3-dask (2024.12.1+dfsg-2) ... 153s Selecting previously unselected package python3-decorator. 153s Preparing to unpack .../119-python3-decorator_5.2.1-2_all.deb ... 153s Unpacking python3-decorator (5.2.1-2) ... 153s Selecting previously unselected package python3-defusedxml. 153s Preparing to unpack .../120-python3-defusedxml_0.7.1-3_all.deb ... 153s Unpacking python3-defusedxml (0.7.1-3) ... 153s Selecting previously unselected package python3-et-xmlfile. 153s Preparing to unpack .../121-python3-et-xmlfile_2.0.0-1_all.deb ... 153s Unpacking python3-et-xmlfile (2.0.0-1) ... 153s Selecting previously unselected package python3-execnet. 153s Preparing to unpack .../122-python3-execnet_2.1.1-1_all.deb ... 153s Unpacking python3-execnet (2.1.1-1) ... 153s Selecting previously unselected package python3-platformdirs. 153s Preparing to unpack .../123-python3-platformdirs_4.3.7-1_all.deb ... 153s Unpacking python3-platformdirs (4.3.7-1) ... 153s Selecting previously unselected package python3-fs. 153s Preparing to unpack .../124-python3-fs_2.4.16-7_all.deb ... 153s Unpacking python3-fs (2.4.16-7) ... 153s Selecting previously unselected package python3-lxml:s390x. 153s Preparing to unpack .../125-python3-lxml_5.4.0-1_s390x.deb ... 153s Unpacking python3-lxml:s390x (5.4.0-1) ... 153s Selecting previously unselected package python3-lz4. 153s Preparing to unpack .../126-python3-lz4_4.4.0+dfsg-2_s390x.deb ... 153s Unpacking python3-lz4 (4.4.0+dfsg-2) ... 153s Selecting previously unselected package python3-scipy. 153s Preparing to unpack .../127-python3-scipy_1.14.1-4ubuntu2_s390x.deb ... 153s Unpacking python3-scipy (1.14.1-4ubuntu2) ... 153s Selecting previously unselected package python3-mpmath. 153s Preparing to unpack .../128-python3-mpmath_1.3.0-1_all.deb ... 153s Unpacking python3-mpmath (1.3.0-1) ... 153s Selecting previously unselected package python3-sympy. 153s Preparing to unpack .../129-python3-sympy_1.13.3-5_all.deb ... 153s Unpacking python3-sympy (1.13.3-5) ... 154s Selecting previously unselected package python3-ufolib2. 154s Preparing to unpack .../130-python3-ufolib2_0.17.1+dfsg1-1_all.deb ... 154s Unpacking python3-ufolib2 (0.17.1+dfsg1-1) ... 154s Selecting previously unselected package unicode-data. 154s Preparing to unpack .../131-unicode-data_15.1.0-1_all.deb ... 154s Unpacking unicode-data (15.1.0-1) ... 154s Selecting previously unselected package python3-fonttools. 154s Preparing to unpack .../132-python3-fonttools_4.55.3-2build1_s390x.deb ... 154s Unpacking python3-fonttools (4.55.3-2build1) ... 154s Selecting previously unselected package python3-webencodings. 154s Preparing to unpack .../133-python3-webencodings_0.5.1-5_all.deb ... 154s Unpacking python3-webencodings (0.5.1-5) ... 154s Selecting previously unselected package python3-html5lib. 154s Preparing to unpack .../134-python3-html5lib_1.2-2_all.deb ... 154s Unpacking python3-html5lib (1.2-2) ... 154s Selecting previously unselected package python3-sortedcontainers. 154s Preparing to unpack .../135-python3-sortedcontainers_2.4.0-2_all.deb ... 154s Unpacking python3-sortedcontainers (2.4.0-2) ... 154s Selecting previously unselected package python3-hypothesis. 154s Preparing to unpack .../136-python3-hypothesis_6.127.4-1_all.deb ... 154s Unpacking python3-hypothesis (6.127.4-1) ... 154s Selecting previously unselected package python3-iniconfig. 154s Preparing to unpack .../137-python3-iniconfig_1.1.1-2_all.deb ... 154s Unpacking python3-iniconfig (1.1.1-2) ... 154s Selecting previously unselected package python3-kiwisolver. 154s Preparing to unpack .../138-python3-kiwisolver_1.4.7-3build1_s390x.deb ... 154s Unpacking python3-kiwisolver (1.4.7-3build1) ... 154s Selecting previously unselected package libopenjp2-7:s390x. 154s Preparing to unpack .../139-libopenjp2-7_2.5.3-2_s390x.deb ... 154s Unpacking libopenjp2-7:s390x (2.5.3-2) ... 154s Selecting previously unselected package python3-pil:s390x. 154s Preparing to unpack .../140-python3-pil_11.1.0-5build1_s390x.deb ... 154s Unpacking python3-pil:s390x (11.1.0-5build1) ... 154s Selecting previously unselected package python3.13-tk. 154s Preparing to unpack .../141-python3.13-tk_3.13.3-1_s390x.deb ... 154s Unpacking python3.13-tk (3.13.3-1) ... 154s Selecting previously unselected package python3-tk:s390x. 154s Preparing to unpack .../142-python3-tk_3.13.3-1_s390x.deb ... 154s Unpacking python3-tk:s390x (3.13.3-1) ... 154s Selecting previously unselected package python3-pil.imagetk:s390x. 154s Preparing to unpack .../143-python3-pil.imagetk_11.1.0-5build1_s390x.deb ... 154s Unpacking python3-pil.imagetk:s390x (11.1.0-5build1) ... 154s Selecting previously unselected package python3-matplotlib. 154s Preparing to unpack .../144-python3-matplotlib_3.10.1+dfsg1-3_s390x.deb ... 154s Unpacking python3-matplotlib (3.10.1+dfsg1-3) ... 154s Selecting previously unselected package python3-numexpr. 154s Preparing to unpack .../145-python3-numexpr_2.10.2-1build2_s390x.deb ... 154s Unpacking python3-numexpr (2.10.2-1build2) ... 154s Selecting previously unselected package python3-odf. 154s Preparing to unpack .../146-python3-odf_1.4.2-4_all.deb ... 154s Unpacking python3-odf (1.4.2-4) ... 154s Selecting previously unselected package python3-openpyxl. 154s Preparing to unpack .../147-python3-openpyxl_3.1.5+dfsg-2_all.deb ... 154s Unpacking python3-openpyxl (3.1.5+dfsg-2) ... 154s Selecting previously unselected package python3-pluggy. 154s Preparing to unpack .../148-python3-pluggy_1.5.0-1_all.deb ... 154s Unpacking python3-pluggy (1.5.0-1) ... 154s Selecting previously unselected package python3-py. 154s Preparing to unpack .../149-python3-py_1.11.0-4_all.deb ... 154s Unpacking python3-py (1.11.0-4) ... 154s Selecting previously unselected package python3-pyqt5.sip. 154s Preparing to unpack .../150-python3-pyqt5.sip_12.17.0-1build1_s390x.deb ... 154s Unpacking python3-pyqt5.sip (12.17.0-1build1) ... 154s Selecting previously unselected package python3-pyqt5. 154s Preparing to unpack .../151-python3-pyqt5_5.15.11+dfsg-2_s390x.deb ... 154s Unpacking python3-pyqt5 (5.15.11+dfsg-2) ... 154s Selecting previously unselected package python3-pyreadstat. 154s Preparing to unpack .../152-python3-pyreadstat_1.2.8-1build1_s390x.deb ... 154s Unpacking python3-pyreadstat (1.2.8-1build1) ... 154s Selecting previously unselected package python3-pytest. 154s Preparing to unpack .../153-python3-pytest_8.3.5-1_all.deb ... 154s Unpacking python3-pytest (8.3.5-1) ... 154s Selecting previously unselected package python3-pytest-asyncio. 154s Preparing to unpack .../154-python3-pytest-asyncio_0.25.1-1_all.deb ... 154s Unpacking python3-pytest-asyncio (0.25.1-1) ... 154s Selecting previously unselected package python3-pytest-forked. 154s Preparing to unpack .../155-python3-pytest-forked_1.6.0-3_all.deb ... 154s Unpacking python3-pytest-forked (1.6.0-3) ... 154s Selecting previously unselected package python3-werkzeug. 154s Preparing to unpack .../156-python3-werkzeug_3.1.3-2_all.deb ... 154s Unpacking python3-werkzeug (3.1.3-2) ... 154s Selecting previously unselected package python3-pytest-localserver. 154s Preparing to unpack .../157-python3-pytest-localserver_0.9.0.post0-1_all.deb ... 154s Unpacking python3-pytest-localserver (0.9.0.post0-1) ... 154s Selecting previously unselected package python3-pytest-xdist. 154s Preparing to unpack .../158-python3-pytest-xdist_3.6.1-1_all.deb ... 154s Unpacking python3-pytest-xdist (3.6.1-1) ... 154s Selecting previously unselected package python3-pytestqt. 154s Preparing to unpack .../159-python3-pytestqt_4.4.0-1_all.deb ... 154s Unpacking python3-pytestqt (4.4.0-1) ... 154s Selecting previously unselected package python3-greenlet. 154s Preparing to unpack .../160-python3-greenlet_3.1.0-1build1_s390x.deb ... 154s Unpacking python3-greenlet (3.1.0-1build1) ... 154s Selecting previously unselected package python3-sqlalchemy. 154s Preparing to unpack .../161-python3-sqlalchemy_2.0.38+ds1-0ubuntu2_all.deb ... 154s Unpacking python3-sqlalchemy (2.0.38+ds1-0ubuntu2) ... 154s Selecting previously unselected package python3-tabulate. 154s Preparing to unpack .../162-python3-tabulate_0.9.0-1_all.deb ... 154s Unpacking python3-tabulate (0.9.0-1) ... 155s Selecting previously unselected package python3-tz. 155s Preparing to unpack .../163-python3-tz_2025.1-3_all.deb ... 155s Unpacking python3-tz (2025.1-3) ... 155s Selecting previously unselected package python3-xarray. 155s Preparing to unpack .../164-python3-xarray_2025.03.1-8_all.deb ... 155s Unpacking python3-xarray (2025.03.1-8) ... 155s Selecting previously unselected package python3-xlrd. 155s Preparing to unpack .../165-python3-xlrd_2.0.1-2_all.deb ... 155s Unpacking python3-xlrd (2.0.1-2) ... 155s Selecting previously unselected package python3-xlsxwriter. 155s Preparing to unpack .../166-python3-xlsxwriter_3.1.9-2_all.deb ... 155s Unpacking python3-xlsxwriter (3.1.9-2) ... 155s Selecting previously unselected package python3-zstandard. 155s Preparing to unpack .../167-python3-zstandard_0.23.0-3build1_s390x.deb ... 155s Unpacking python3-zstandard (0.23.0-3build1) ... 155s Selecting previously unselected package tzdata-legacy. 155s Preparing to unpack .../168-tzdata-legacy_2025b-1ubuntu1_all.deb ... 155s Unpacking tzdata-legacy (2025b-1ubuntu1) ... 155s Selecting previously unselected package x11-xkb-utils. 155s Preparing to unpack .../169-x11-xkb-utils_7.7+9_s390x.deb ... 155s Unpacking x11-xkb-utils (7.7+9) ... 155s Selecting previously unselected package xsel. 155s Preparing to unpack .../170-xsel_1.2.1-1_s390x.deb ... 155s Unpacking xsel (1.2.1-1) ... 155s Selecting previously unselected package xserver-common. 155s Preparing to unpack .../171-xserver-common_2%3a21.1.16-1ubuntu1_all.deb ... 155s Unpacking xserver-common (2:21.1.16-1ubuntu1) ... 155s Selecting previously unselected package xvfb. 155s Preparing to unpack .../172-xvfb_2%3a21.1.16-1ubuntu1_s390x.deb ... 155s Unpacking xvfb (2:21.1.16-1ubuntu1) ... 155s Selecting previously unselected package locales-all. 155s Preparing to unpack .../173-locales-all_2.41-6ubuntu1_s390x.deb ... 155s Unpacking locales-all (2.41-6ubuntu1) ... 156s Setting up libgraphite2-3:s390x (1.3.14-2ubuntu1) ... 156s Setting up xsel (1.2.1-1) ... 156s Setting up libxcb-dri3-0:s390x (1.17.0-2) ... 156s Setting up liblcms2-2:s390x (2.16-2) ... 156s Setting up python3-iniconfig (1.1.1-2) ... 156s Setting up libpixman-1-0:s390x (0.44.0-3) ... 156s Setting up libsharpyuv0:s390x (1.5.0-0.1) ... 156s Setting up libwayland-server0:s390x (1.23.1-3) ... 156s Setting up libx11-xcb1:s390x (2:1.8.12-1) ... 156s Setting up libdouble-conversion3:s390x (3.3.1-1) ... 156s Setting up libxcb-xfixes0:s390x (1.17.0-2) ... 156s Setting up libxpm4:s390x (1:3.5.17-1build2) ... 156s Setting up python3-async-generator (1.10-4) ... 156s Setting up libxcb-xinput0:s390x (1.17.0-2) ... 156s Setting up libxrender1:s390x (1:0.9.12-1) ... 156s Setting up python3-py (1.11.0-4) ... 156s Setting up python3-lz4 (4.4.0+dfsg-2) ... 156s Setting up libxcb-render0:s390x (1.17.0-2) ... 156s Setting up python3-defusedxml (0.7.1-3) ... 156s Setting up libglvnd0:s390x (1.7.0-1build1) ... 156s Setting up fonts-lyx (2.4.3-1) ... 156s Setting up libxcb-glx0:s390x (1.17.0-2) ... 156s Setting up python3-fsspec (2025.3.0-1) ... 157s Setting up libxcb-keysyms1:s390x (0.4.1-1) ... 157s Setting up libxcb-shape0:s390x (1.17.0-2) ... 157s Setting up x11-common (1:7.7+23ubuntu4) ... 157s Setting up libdeflate0:s390x (1.23-2) ... 157s Setting up python3-tabulate (0.9.0-1) ... 157s Setting up libqhull-r8.0:s390x (2020.2-6build1) ... 157s Setting up libxcb-render-util0:s390x (0.3.10-1) ... 157s Setting up python3-all (3.13.3-1) ... 157s Setting up libxcb-shm0:s390x (1.17.0-2) ... 157s Setting up libxcb-icccm4:s390x (0.4.2-1) ... 157s Setting up python3-sortedcontainers (2.4.0-2) ... 157s Setting up libgomp1:s390x (15.1.0-2ubuntu1) ... 157s Setting up python3-click (8.2.0+0.really.8.1.8-1) ... 157s Setting up libjbig0:s390x (2.1-6.1ubuntu2) ... 157s Setting up python3-webencodings (0.5.1-5) ... 157s Setting up python3-pyreadstat (1.2.8-1build1) ... 157s Setting up locales-all (2.41-6ubuntu1) ... 157s Setting up libpcre2-16-0:s390x (10.45-1) ... 157s Setting up python3-platformdirs (4.3.7-1) ... 157s Setting up tzdata-legacy (2025b-1ubuntu1) ... 157s Setting up python3-tz (2025.1-3) ... 157s Setting up libxcb-util1:s390x (0.4.1-1) ... 157s Setting up libxxf86vm1:s390x (1:1.1.4-1build4) ... 157s Setting up python3-cloudpickle (3.1.1-1) ... 157s Setting up libxcb-xkb1:s390x (1.17.0-2) ... 157s Setting up libxcb-image0:s390x (0.4.0-2build1) ... 157s Setting up python3-fs (2.4.16-7) ... 158s Setting up libxcb-present0:s390x (1.17.0-2) ... 158s Setting up unicode-data (15.1.0-1) ... 158s Setting up libqt5core5t64:s390x (5.15.15+dfsg-4ubuntu1) ... 158s Setting up python3-decorator (5.2.1-2) ... 158s Setting up libfontenc1:s390x (1:1.1.8-1build1) ... 158s Setting up python3-zstandard (0.23.0-3build1) ... 158s Setting up python3-packaging (25.0-1) ... 158s Setting up libxcb-xinerama0:s390x (1.17.0-2) ... 158s Setting up python3-xlsxwriter (3.1.9-2) ... 158s Setting up libfreetype6:s390x (2.13.3+dfsg-1) ... 158s Setting up libxcb-sync1:s390x (1.17.0-2) ... 158s Setting up python3-werkzeug (3.1.3-2) ... 158s Setting up python3-brotli (1.1.0-2build4) ... 158s Setting up libavahi-common-data:s390x (0.8-16ubuntu2) ... 158s Setting up python3-greenlet (3.1.0-1build1) ... 158s Setting up python3-cycler (0.12.1-1) ... 158s Setting up libimagequant0:s390x (2.18.0-1build1) ... 158s Setting up libxkbcommon-x11-0:s390x (1.7.0-2) ... 158s Setting up fonts-dejavu-mono (2.37-8) ... 158s Setting up python3-kiwisolver (1.4.7-3build1) ... 158s Setting up python3-bottleneck (1.4.2+ds1-2build1) ... 159s Setting up libxrandr2:s390x (2:1.5.4-1) ... 159s Setting up libtcl8.6:s390x (8.6.16+dfsg-1) ... 159s Setting up fonts-dejavu-core (2.37-8) ... 159s Setting up python3-numexpr (2.10.2-1build2) ... 159s Setting up libjpeg-turbo8:s390x (2.1.5-3ubuntu2) ... 159s Setting up python3-html5lib (1.2-2) ... 159s Setting up libvulkan1:s390x (1.4.309.0-1) ... 159s Setting up python3-pluggy (1.5.0-1) ... 159s Setting up libwebp7:s390x (1.5.0-0.1) ... 159s Setting up python3-pyqt5.sip (12.17.0-1build1) ... 159s Setting up libmtdev1t64:s390x (1.1.7-1) ... 159s Setting up libxshmfence1:s390x (1.3.3-1) ... 159s Setting up libxcb-randr0:s390x (1.17.0-2) ... 159s Setting up libxslt1.1:s390x (1.1.39-0exp1ubuntu4) ... 159s Setting up python3-et-xmlfile (2.0.0-1) ... 159s Setting up libqt5sql5t64:s390x (5.15.15+dfsg-4ubuntu1) ... 159s Setting up libmd4c0:s390x (0.5.2-2) ... 159s Setting up python3-xlrd (2.0.1-2) ... 159s Setting up libopenjp2-7:s390x (2.5.3-2) ... 159s Setting up python3-toolz (1.0.0-2) ... 159s Setting up libharfbuzz0b:s390x (10.2.0-1) ... 159s Setting up python3-contourpy (1.3.1-1build1) ... 159s Setting up libxss1:s390x (1:1.2.3-1build3) ... 159s Setting up libxkbfile1:s390x (1:1.1.0-1build4) ... 159s Setting up libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 159s Setting up python3-mpmath (1.3.0-1) ... 160s Setting up python3-execnet (2.1.1-1) ... 160s Setting up python-matplotlib-data (3.10.1+dfsg1-3) ... 160s Setting up libwebpmux3:s390x (1.5.0-0.1) ... 160s Setting up python3-locket (1.0.0-2) ... 160s Setting up libxfont2:s390x (1:2.0.6-1build1) ... 160s Setting up python3-soupsieve (2.7-1) ... 160s Setting up liblbfgsb0:s390x (3.0+dfsg.4-1build1) ... 160s Setting up python3-odf (1.4.2-4) ... 160s Setting up libwacom-common (2.14.0-1) ... 160s Setting up libwayland-client0:s390x (1.23.1-3) ... 160s Setting up libjpeg8:s390x (8c-2ubuntu11) ... 160s Setting up python3-partd (1.4.2-1) ... 160s Setting up python3-sympy (1.13.3-5) ... 164s Setting up libice6:s390x (2:1.1.1-1) ... 164s Setting up mesa-libgallium:s390x (25.0.3-1ubuntu2) ... 164s Setting up libqt5dbus5t64:s390x (5.15.15+dfsg-4ubuntu1) ... 164s Setting up python3-scipy (1.14.1-4ubuntu2) ... 167s Setting up libgbm1:s390x (25.0.3-1ubuntu2) ... 167s Setting up libwacom9:s390x (2.14.0-1) ... 167s Setting up fontconfig-config (2.15.0-2.2ubuntu1) ... 167s Setting up python3-pytest (8.3.5-1) ... 167s Setting up python3-pytest-localserver (0.9.0.post0-1) ... 167s Setting up libwebpdemux2:s390x (1.5.0-0.1) ... 167s Setting up python3-hypothesis (6.127.4-1) ... 167s Setting up python3-xarray (2025.03.1-8) ... 168s Setting up libgl1-mesa-dri:s390x (25.0.3-1ubuntu2) ... 168s Setting up libqt5network5t64:s390x (5.15.15+dfsg-4ubuntu1) ... 168s Setting up libavahi-common3:s390x (0.8-16ubuntu2) ... 168s Setting up python3-dask (2024.12.1+dfsg-2) ... 169s Setting up libqt5xml5t64:s390x (5.15.15+dfsg-4ubuntu1) ... 169s Setting up libqt5test5t64:s390x (5.15.15+dfsg-4ubuntu1) ... 169s Setting up python3-bs4 (4.13.4-1) ... 169s Setting up python3-sqlalchemy (2.0.38+ds1-0ubuntu2) ... 170s Setting up libinput-bin (1.28.1-1) ... 170s Setting up python3-pytest-forked (1.6.0-3) ... 170s Setting up libegl-mesa0:s390x (25.0.3-1ubuntu2) ... 170s Setting up libjs-jquery-ui (1.13.2+dfsg-1) ... 170s Setting up libraqm0:s390x (0.10.2-1) ... 170s Setting up python3-pytest-asyncio (0.25.1-1) ... 170s Setting up python3-lxml:s390x (5.4.0-1) ... 170s Setting up libtiff6:s390x (4.7.0-3ubuntu1) ... 170s Setting up libegl1:s390x (1.7.0-1build1) ... 170s Setting up libfontconfig1:s390x (2.15.0-2.2ubuntu1) ... 170s Setting up libsm6:s390x (2:1.2.6-1) ... 170s Setting up python3-pytestqt (4.4.0-1) ... 170s Setting up libavahi-client3:s390x (0.8-16ubuntu2) ... 170s Setting up libinput10:s390x (1.28.1-1) ... 170s Setting up fontconfig (2.15.0-2.2ubuntu1) ... 172s Regenerating fonts cache... done. 172s Setting up libxft2:s390x (2.3.6-1build1) ... 172s Setting up libglx-mesa0:s390x (25.0.3-1ubuntu2) ... 172s Setting up python3-pytest-xdist (3.6.1-1) ... 173s Setting up libglx0:s390x (1.7.0-1build1) ... 173s Setting up libtk8.6:s390x (8.6.16-1) ... 173s Setting up python3.13-tk (3.13.3-1) ... 173s Setting up python3-pil:s390x (11.1.0-5build1) ... 173s Setting up libgl1:s390x (1.7.0-1build1) ... 173s Setting up python3-openpyxl (3.1.5+dfsg-2) ... 173s Setting up libxt6t64:s390x (1:1.2.1-1.2build1) ... 173s Setting up libcups2t64:s390x (2.4.12-0ubuntu1) ... 173s Setting up tk8.6-blt2.5 (2.5.3+dfsg-8) ... 173s Setting up libxmu6:s390x (2:1.1.3-3build2) ... 173s Setting up blt (2.5.3+dfsg-8) ... 173s Setting up python3-tk:s390x (3.13.3-1) ... 173s Setting up libxaw7:s390x (2:1.0.16-1) ... 173s Setting up libqt5gui5t64:s390x (5.15.15+dfsg-4ubuntu1) ... 173s Setting up python3-pil.imagetk:s390x (11.1.0-5build1) ... 173s Setting up libqt5widgets5t64:s390x (5.15.15+dfsg-4ubuntu1) ... 173s Setting up x11-xkb-utils (7.7+9) ... 173s Setting up libqt5help5:s390x (5.15.15-6build1) ... 173s Setting up xserver-common (2:21.1.16-1ubuntu1) ... 173s Setting up libqt5printsupport5t64:s390x (5.15.15+dfsg-4ubuntu1) ... 173s Setting up libqt5designer5:s390x (5.15.15-6build1) ... 173s Setting up xvfb (2:21.1.16-1ubuntu1) ... 173s Setting up python3-pyqt5 (5.15.11+dfsg-2) ... 173s Setting up python3-ufolib2 (0.17.1+dfsg1-1) ... 173s Setting up python3-fonttools (4.55.3-2build1) ... 174s Setting up python3-matplotlib (3.10.1+dfsg1-3) ... 175s Processing triggers for libc-bin (2.41-6ubuntu1) ... 175s Processing triggers for man-db (2.13.1-1) ... 175s Processing triggers for udev (257.4-1ubuntu3) ... 176s autopkgtest [17:26:36]: test unittests3: [----------------------- 176s ++ dpkg --print-architecture 176s + arch=s390x 176s ++ py3versions -s 176s + pys=python3.13 176s + sourcetestroot=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests 176s + tomlfile=/tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 176s + echo amd64 i386 176s + grep s390x 176s + marker='not slow' 176s + echo s390x 176s + grep -E 'mips|hppa' 176s + PYTEST_WARN_IGNORE= 176s + cd /tmp/autopkgtest.VZGv7J/autopkgtest_tmp 176s + TEST_SUCCESS=true 176s + for py in $pys 176s + echo '=== python3.13 ===' 176s === python3.13 === 176s ++ python3.13 -c 'import pandas as pd; print(pd.__path__[0])' 177s + modpath=/usr/lib/python3/dist-packages/pandas 177s + for TEST_SUBSET in $modpath/tests/* 177s + echo /usr/lib/python3/dist-packages/pandas/tests/__init__.py 177s + grep -q -e __pycache__ 177s + PANDAS_CI=1 177s + LC_ALL=C.UTF-8 177s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/__init__.py 177s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 177s 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" 177s 177s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 177s ============================= test session starts ============================== 177s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 177s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 177s rootdir: /usr/lib/python3/dist-packages/pandas 177s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 177s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 177s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 177s collected 0 items 177s 177s =============================== warnings summary =============================== 177s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 177s /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-8zoshu9a' 177s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 177s 177s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 177s /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-mddmqmfz' 177s session.config.cache.set(STEPWISE_CACHE_DIR, []) 177s 177s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 177s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 177s ============================= 2 warnings in 0.07s ============================== 177s rdjoqkol test state = true 177s + test 5 == 5 177s + echo 'rdjoqkol test state = true' 177s + for TEST_SUBSET in $modpath/tests/* 177s + echo /usr/lib/python3/dist-packages/pandas/tests/__pycache__ 177s + grep -q -e __pycache__ 177s + echo 'rdjoqkol test state = true' 177s + for TEST_SUBSET in $modpath/tests/* 177s rdjoqkol test state = true 177s + echo /usr/lib/python3/dist-packages/pandas/tests/api 177s + grep -q -e __pycache__ 177s + PANDAS_CI=1 177s + LC_ALL=C.UTF-8 177s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/api 178s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 178s 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" 178s 178s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 178s ============================= test session starts ============================== 178s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 178s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 178s rootdir: /usr/lib/python3/dist-packages/pandas 178s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 178s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 178s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 178s collected 14 items 178s 178s ../../../usr/lib/python3/dist-packages/pandas/tests/api/test_api.py ............ 178s ../../../usr/lib/python3/dist-packages/pandas/tests/api/test_types.py .. 178s 178s =============================== warnings summary =============================== 178s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 178s /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-xy4jzsnz' 178s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 178s 178s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 178s /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-c77f_h_p' 178s session.config.cache.set(STEPWISE_CACHE_DIR, []) 178s 178s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 178s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 178s ============================= slowest 30 durations ============================= 178s 178s (30 durations < 0.005s hidden. Use -vv to show these durations.) 178s ======================== 14 passed, 2 warnings in 0.09s ======================== 178s rdjoqkol test state = true 178s + echo 'rdjoqkol test state = true' 178s + for TEST_SUBSET in $modpath/tests/* 178s + echo /usr/lib/python3/dist-packages/pandas/tests/apply 178s + grep -q -e __pycache__ 178s + PANDAS_CI=1 178s + LC_ALL=C.UTF-8 178s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/apply 179s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 179s 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" 179s 179s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 179s ============================= test session starts ============================== 179s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 179s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 179s rootdir: /usr/lib/python3/dist-packages/pandas 179s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 179s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 179s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 179s collected 1243 items 179s 179s ../../../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....... 180s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_frame_apply_relabeling.py ..x.. 180s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_frame_transform.py ...s.s.s................................................ss..ss..ss.....x........x........x........ 180s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_invalid_arg.py ....................................................................................................................................................................................................... 180s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_numba.py sssssssssssssssssss 181s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_series_apply.py ................................x.....x....x........................................................................................ 181s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_series_apply_relabeling.py .. 181s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_series_transform.py ............ 182s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_str.py ....................xxxxx...................................................................................................................................................................................................................................................................................................................................................................................................................................................................x...........x...........x...........x...........x........ 182s 182s =============================== warnings summary =============================== 182s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 182s /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-y1f0jgqz' 182s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 182s 182s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 182s /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-1ufn7h64' 182s session.config.cache.set(STEPWISE_CACHE_DIR, []) 182s 182s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 182s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 182s ============================= slowest 30 durations ============================= 182s 0.03s call tests/apply/test_frame_apply.py::test_apply_differently_indexed 182s 0.02s call tests/apply/test_frame_apply.py::test_agg_transform[axis=1] 182s 0.02s call tests/apply/test_frame_apply.py::test_agg_transform[axis='columns'] 182s 0.01s call tests/apply/test_frame_apply.py::test_agg_reduce[axis=1] 182s 0.01s call tests/apply/test_frame_apply.py::test_agg_reduce[axis='columns'] 182s 0.01s call tests/apply/test_frame_transform.py::test_transform_listlike[axis=1-ops3-names3] 182s 0.01s call tests/apply/test_frame_transform.py::test_transform_listlike[axis='columns'-ops3-names3] 182s 0.01s call tests/apply/test_frame_transform.py::test_transform_listlike[axis='columns'-ops1-names1] 182s 0.01s call tests/apply/test_frame_transform.py::test_transform_listlike[axis=1-ops1-names1] 182s 0.01s call tests/apply/test_frame_transform.py::test_transform_listlike[axis=1-ops0-names0] 182s 0.01s call tests/apply/test_frame_transform.py::test_transform_listlike[axis='columns'-ops0-names0] 182s 0.01s call tests/apply/test_frame_transform.py::test_transform_listlike[axis='columns'-ops2-names2] 182s 0.01s call tests/apply/test_frame_transform.py::test_transform_listlike[axis=1-ops2-names2] 182s 0.01s call tests/apply/test_series_apply.py::test_transform[False] 182s 0.01s call tests/apply/test_series_apply.py::test_transform[compat] 182s 0.01s call tests/apply/test_str.py::test_transform_groupby_kernel_frame[axis=1-pct_change] 182s 0.01s call tests/apply/test_str.py::test_transform_groupby_kernel_frame[axis='columns'-pct_change] 182s 0.01s call tests/apply/test_frame_apply.py::test_agg_reduce[axis=0] 182s 0.01s call tests/apply/test_frame_apply.py::test_agg_reduce[axis='index'] 182s 0.01s call tests/apply/test_frame_apply_relabeling.py::test_agg_namedtuple 182s 0.01s call tests/apply/test_frame_apply.py::test_apply_mutating 182s 0.01s call tests/apply/test_frame_apply.py::test_agg_transform[axis=0] 182s 0.01s call tests/apply/test_series_apply.py::test_with_nested_series[agg] 182s 0.01s call tests/apply/test_frame_apply.py::test_agg_transform[axis='index'] 182s 0.01s call tests/apply/test_series_apply.py::test_with_nested_series[apply] 182s 182s (5 durations < 0.005s hidden. Use -vv to show these durations.) 182s =========== 1153 passed, 73 skipped, 17 xfailed, 2 warnings in 3.87s =========== 183s rdjoqkol test state = true 183s + echo 'rdjoqkol test state = true' 183s + for TEST_SUBSET in $modpath/tests/* 183s + echo /usr/lib/python3/dist-packages/pandas/tests/arithmetic 183s + grep -q -e __pycache__ 183s + PANDAS_CI=1 183s + LC_ALL=C.UTF-8 183s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/arithmetic 183s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 183s 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" 183s 183s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 184s ============================= test session starts ============================== 184s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 184s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 184s rootdir: /usr/lib/python3/dist-packages/pandas 184s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 184s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 184s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 184s collected 19330 items 184s 184s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_array_ops.py .. 184s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_categorical.py .. 214s ../../../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................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 214s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_interval.py ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 218s ../../../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............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 218s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_object.py .......s........................................................................................... 219s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_period.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 221s ../../../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......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 221s 221s =============================== warnings summary =============================== 221s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 221s /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-0z3y6wtj' 221s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 221s 221s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 221s /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-__b3vq9b' 221s session.config.cache.set(STEPWISE_CACHE_DIR, []) 221s 221s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 221s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 221s ============================= slowest 30 durations ============================= 221s 0.12s call tests/arithmetic/test_datetime64.py::TestDatetimeIndexArithmetic::test_dti_addsub_object_arraylike[None-Series-Index] 221s 0.09s call tests/arithmetic/test_datetime64.py::TestDatetime64Arithmetic::test_dt64arr_sub_timedeltalike_scalar[pytz.FixedOffset(300)-timedelta64_0-DataFrame] 221s 0.08s teardown tests/arithmetic/test_timedelta64.py::test_add_timestamp_to_timedelta 221s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_relativedelta_offsets[DataFrame-s] 221s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_relativedelta_offsets[DataFrame-ms] 221s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_relativedelta_offsets[DataFrame-ns] 221s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_relativedelta_offsets[DataFrame-us] 221s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-5-True-cls_and_kwargs27] 221s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-5-True-cls_and_kwargs27] 221s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-us-5-True-cls_and_kwargs27] 221s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-5-False-cls_and_kwargs27] 221s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-5-False-cls_and_kwargs27] 221s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-us-5-False-cls_and_kwargs27] 221s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ns-5-True-cls_and_kwargs27] 221s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ns-5-False-cls_and_kwargs27] 221s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-ms-5-True-cls_and_kwargs27] 221s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-s-5-True-cls_and_kwargs27] 221s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-ms-5-False-cls_and_kwargs27] 221s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-s-5-False-cls_and_kwargs27] 221s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-us-5-True-cls_and_kwargs27] 221s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-ns-5-True-cls_and_kwargs27] 221s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-us-5-False-cls_and_kwargs27] 221s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-ns-5-False-cls_and_kwargs27] 221s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[Series-US/Central-s-5-True-cls_and_kwargs27] 221s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-0-True-CBMonthBegin] 221s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-0-True-CBMonthBegin] 221s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-us-0-True-CBMonthBegin] 221s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-5-True-CBMonthBegin] 221s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-us-5-True-CBMonthBegin] 221s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[Series-US/Central-ms-5-True-cls_and_kwargs27] 221s =============== 19158 passed, 172 skipped, 2 warnings in 38.14s ================ 222s + echo 'rdjoqkol test state = true' 222s + for TEST_SUBSET in $modpath/tests/* 222s rdjoqkol test state = true 222s + echo /usr/lib/python3/dist-packages/pandas/tests/arrays 222s + grep -q -e __pycache__ 222s + PANDAS_CI=1 222s + LC_ALL=C.UTF-8 222s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/arrays 222s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 222s 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" 222s 222s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 224s ============================= test session starts ============================== 224s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 224s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 224s rootdir: /usr/lib/python3/dist-packages/pandas 224s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 224s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 224s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 224s collected 19230 items / 2 skipped 224s 224s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_arithmetic.py ..................... 224s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_astype.py ... 224s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_comparison.py .................................... 225s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_construction.py ............................. 225s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_function.py ........... 225s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_indexing.py ... 225s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_logical.py ................................................................................... 225s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_ops.py .. 225s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_reduction.py .............................. 225s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_repr.py . 225s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_algos.py .............. 225s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_analytics.py ........x..x................................................ 225s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_api.py ................................................................. 225s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_astype.py ...................... 225s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_constructors.py ....................................................................................................................... 225s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_dtypes.py .................................. 225s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_indexing.py ............................................................................................................................................... 225s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_map.py ............................. 225s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_missing.py .......................... 225s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_operators.py ...................................... 225s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_replace.py ...................... 225s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_repr.py ....................... 225s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_sorting.py .... 225s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_subclass.py ... 225s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_take.py ................ 225s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_warnings.py s 225s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/datetimes/test_constructors.py ......................ssssssssssssss 225s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/datetimes/test_cumulative.py ... 226s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/datetimes/test_reductions.py ................................................................................................................................................................................................................. 226s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_arithmetic.py .............................................................. 226s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_astype.py ......... 226s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_comparison.py .................................................................................................................. 226s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_concat.py ... 226s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_construction.py ............................... 226s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_contains.py . 226s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_function.py .................................................... 226s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_repr.py ........ 226s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_to_numpy.py .............................. 226s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_arithmetic.py ................................................................................................................................................................................................................................................................................................................................................... 227s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_comparison.py ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 227s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_concat.py .................. 227s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_construction.py ............................................... 227s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_dtypes.py ......................................................................................................................... 227s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_function.py ............................................................................................................................. 227s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_indexing.py .. 227s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_reduction.py ............................................... 227s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_repr.py .......................... 227s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_astype.py .. 227s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_formats.py . 227s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_interval.py .............................................................................. 227s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_interval_pyarrow.py ssssssss 227s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_overlaps.py .................................................................................................................... 228s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/masked/test_arithmetic.py ..............................................................................................................................................ss........................................................................................................................................................ss........................................................................................................................................................ss........................................................................................................................................................ss........................................................................................................................................................ss............................................................................................................................................................................................................................................................................................................................................................... 228s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/masked/test_function.py ..................... 229s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/masked/test_indexing.py ........................................................................................................... 229s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/numpy_/test_indexing.py ....................................... 229s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/numpy_/test_numpy.py ....................................................................................... 229s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/period/test_astype.py .......... 229s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/period/test_constructors.py ..................... 229s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/period/test_reductions.py ... 229s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_accessor.py ............................................. 230s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_arithmetics.py ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 230s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_array.py ........................................................................... 230s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_astype.py ........................ 230s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_combine_concat.py .......... 230s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_constructors.py ................................. 230s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_dtype.py ........................................................ 230s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_indexing.py ................................................................................ 230s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_libsparse.py ..................................................................................... 230s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_reductions.py ....................................................................... 230s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_unary.py ......... 231s ../../../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 231s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/string_/test_string_arrow.py s.ss.ssssssssss.ssssssssssssssssssssssssssssssssss 231s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_array.py ....................................................................................... 242s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_datetimelike.py ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ssssss....................................................................................................................................................................................................ssssssssssssssssssssssssssssssssssss.......................................................................................................................................................................................................................................................................................................................................... 245s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_datetimes.py ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 245s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_ndarray_backed.py ..... 245s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_period.py ................... 245s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_timedeltas.py ...................................................................................................................................................... 245s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/timedeltas/test_constructors.py ........ 245s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/timedeltas/test_cumulative.py ..... 246s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/timedeltas/test_reductions.py .......................... 246s 246s =============================== warnings summary =============================== 246s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 246s /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-im_d5b1r' 246s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 246s 246s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 246s /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-i6lkz3f0' 246s session.config.cache.set(STEPWISE_CACHE_DIR, []) 246s 246s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 246s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 246s ============================= slowest 30 durations ============================= 246s 0.14s call tests/arrays/test_timedeltas.py::TestNonNano::test_mul_listlike_object[s] 246s 0.10s call tests/arrays/test_datetimelike.py::TestDatetimeArray::test_setitem_object_dtype['UTC+01:15'-QE-Index] 246s 0.09s teardown tests/arrays/timedeltas/test_reductions.py::TestReductions::test_mean_2d 246s 0.09s setup tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_bool_array_logical[integer-True] 246s 0.06s call tests/arrays/sparse/test_accessor.py::TestSeriesAccessor::test_from_coo 246s 0.04s call tests/arrays/categorical/test_dtypes.py::TestCategoricalDtypes::test_codes_dtypes 246s 0.01s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_mixed_array_comparison[block] 246s 0.01s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_mixed_array_comparison[integer] 246s 0.01s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_float_scalar_comparison[block] 246s 0.01s call tests/arrays/integer/test_arithmetic.py::test_values_multiplying_large_series_by_NA 246s 0.01s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_int_array_comparison[integer] 246s 0.01s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_int_array_comparison[block] 246s 0.01s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_float_scalar_comparison[integer] 246s 0.01s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_float_array_comparison[integer] 246s 0.01s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_float_array_comparison[block] 246s 246s (15 durations < 0.005s hidden. Use -vv to show these durations.) 246s ========= 18203 passed, 1021 skipped, 8 xfailed, 2 warnings in 23.52s ========== 246s rdjoqkol test state = true 246s + echo 'rdjoqkol test state = true' 246s + for TEST_SUBSET in $modpath/tests/* 246s + echo /usr/lib/python3/dist-packages/pandas/tests/base 246s + grep -q -e __pycache__ 246s + PANDAS_CI=1 246s + LC_ALL=C.UTF-8 246s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/base 247s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 247s 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" 247s 247s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 247s ============================= test session starts ============================== 247s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 247s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 247s rootdir: /usr/lib/python3/dist-packages/pandas 247s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 247s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 247s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 247s collected 1775 items 247s 247s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_constructors.py ....................... 247s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_conversion.py ................................................................................................................................................................................................................................................................................................................................... 247s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_fillna.py ..................................................................................ssssssssssssssssss....ssss........ssssssssss......ss..............................................ss......................ssssssssssss 248s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_misc.py .......................................................................................................................................................................................................................................xx...xxx....................................................................s...... 248s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_transpose.py .............................................................................................................................................................................................................................. 248s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_unique.py ..................................................................................ssssssssssssssssss....ssss........ssssssssss......ss..............................................ss......................ssssssssssss..................................................................................ssssssssssssssssss....ssss..........ssssssss......ss......................................................................ssssssssssss.... 249s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_value_counts.py ..................................................................................ssssssssssssssssss....ssss........ssssssssss......ss..............................................ss......................ssssssssssss......................... 249s 249s =============================== warnings summary =============================== 249s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 249s /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-ao8m91r7' 249s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 249s 249s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 249s /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-pqihacou' 249s session.config.cache.set(STEPWISE_CACHE_DIR, []) 249s 249s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 249s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 249s ============================= slowest 30 durations ============================= 249s 0.02s setup tests/base/test_misc.py::test_memory_usage[series-with-string-python-index] 249s 0.02s call tests/base/test_value_counts.py::test_value_counts_null[interval-nan] 249s 0.02s call tests/base/test_value_counts.py::test_value_counts_null[interval-None] 249s 0.01s call tests/base/test_value_counts.py::test_value_counts[interval] 249s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[datetime-tz-nan] 249s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[datetime-tz-None] 249s 0.01s call tests/base/test_value_counts.py::test_value_counts[datetime-tz] 249s 0.01s call tests/base/test_unique.py::test_unique_null[datetime-tz-nan] 249s 0.01s call tests/base/test_unique.py::test_unique_null[datetime-tz-None] 249s 0.01s call tests/base/test_unique.py::test_unique[datetime-tz] 249s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[period-nan] 249s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[period-None] 249s 0.01s call tests/base/test_unique.py::test_unique_null[timedelta-None] 249s 0.01s call tests/base/test_unique.py::test_unique_null[timedelta-nan] 249s 0.01s call tests/base/test_unique.py::test_unique[timedelta] 249s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[timedelta-nan] 249s 0.01s call tests/base/test_unique.py::test_unique_null[datetime-None] 249s 0.01s call tests/base/test_value_counts.py::test_value_counts_bins[index] 249s 0.01s call tests/base/test_unique.py::test_unique_null[datetime-nan] 249s 0.01s call tests/base/test_unique.py::test_unique[datetime] 249s 0.01s call tests/base/test_value_counts.py::test_value_counts[timedelta] 249s 0.01s teardown tests/base/test_value_counts.py::test_value_counts_object_inference_deprecated 249s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[timedelta-None] 249s 0.01s call tests/base/test_value_counts.py::test_value_counts[period] 249s 0.01s call tests/base/test_value_counts.py::test_value_counts_bins[series] 249s 0.01s call tests/base/test_unique.py::test_unique_null[period-nan] 249s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[datetime-nan] 249s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[datetime-None] 249s 0.01s call tests/base/test_unique.py::test_unique[period] 249s 0.01s call tests/base/test_unique.py::test_unique_null[period-None] 249s =========== 1581 passed, 189 skipped, 5 xfailed, 2 warnings in 2.31s =========== 249s rdjoqkol test state = true 249s + echo 'rdjoqkol test state = true' 249s + for TEST_SUBSET in $modpath/tests/* 249s + echo /usr/lib/python3/dist-packages/pandas/tests/computation 249s + grep -q -e __pycache__ 249s + PANDAS_CI=1 249s + LC_ALL=C.UTF-8 249s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/computation 249s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 249s 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" 249s 249s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 250s ============================= test session starts ============================== 250s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 250s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 250s rootdir: /usr/lib/python3/dist-packages/pandas 250s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 250s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 250s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 250s collected 11159 items 250s 250s ../../../usr/lib/python3/dist-packages/pandas/tests/computation/test_compat.py ..... 281s ../../../usr/lib/python3/dist-packages/pandas/tests/computation/test_eval.py ..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................xx..............................xx..............................xx..............................xx.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................xxxxxxxxxx..................................................xxxxxxxxxx......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................X.........X....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x....................................................................................................................................................................................................................................xx..xx..... 281s 281s =============================== warnings summary =============================== 281s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 281s /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-3scgvf2f' 281s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 281s 281s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 281s /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-dsnrthh2' 281s session.config.cache.set(STEPWISE_CACHE_DIR, []) 281s 281s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 281s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 281s ============================= slowest 30 durations ============================= 281s 0.08s call tests/computation/test_eval.py::TestEval::test_floor_division[Series-SeriesNaN-numexpr-python] 281s 0.06s call tests/computation/test_eval.py::TestAlignment::test_performance_warning_for_poor_alignment[numexpr-python] 281s 0.06s call tests/computation/test_eval.py::TestEval::test_complex_cmp_ops[SeriesNaN-Series-numexpr-pandas-or-lt-le] 281s 0.05s teardown tests/computation/test_eval.py::TestValidate::test_validate_bool_args[5.0] 281s 0.04s call tests/computation/test_eval.py::TestAlignment::test_performance_warning_for_poor_alignment[numexpr-pandas] 281s 0.02s call tests/computation/test_eval.py::TestAlignment::test_performance_warning_for_poor_alignment[python-python] 281s 0.02s call tests/computation/test_eval.py::TestAlignment::test_performance_warning_for_poor_alignment[python-pandas] 281s 0.01s call tests/computation/test_eval.py::TestOperations::test_simple_arith_ops[numexpr-python] 281s 0.01s call tests/computation/test_eval.py::TestOperations::test_lhs_expression_subscript 281s 0.01s call tests/computation/test_eval.py::TestOperations::test_nested_period_index_subscript_expression 281s 0.01s call tests/computation/test_eval.py::TestOperations::test_check_many_exprs[numexpr-python] 281s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[numexpr-pandas-&] 281s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[numexpr-pandas-|] 281s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[numexpr-python-|] 281s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[python-pandas-&] 281s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[numexpr-python-&] 281s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[python-pandas-|] 281s 0.01s call tests/computation/test_eval.py::TestOperations::test_attr_expression 281s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[python-python-|] 281s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[python-python-&] 281s 0.01s call tests/computation/test_eval.py::TestOperations::test_check_many_exprs[numexpr-pandas] 281s 0.01s call tests/computation/test_eval.py::TestOperations::test_simple_arith_ops[numexpr-pandas] 281s 0.01s call tests/computation/test_eval.py::TestOperations::test_check_many_exprs[python-pandas] 281s 0.01s call tests/computation/test_eval.py::TestOperations::test_check_many_exprs[python-python] 281s 0.01s call tests/computation/test_eval.py::TestOperations::test_multi_line_expression 281s 0.01s call tests/computation/test_eval.py::TestOperations::test_simple_arith_ops[python-python] 281s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[python-pandas-dt-i-i-dt] 281s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[python-pandas-dt-dt-i-i] 281s 281s (2 durations < 0.005s hidden. Use -vv to show these durations.) 281s ========== 11124 passed, 33 xfailed, 2 xpassed, 2 warnings in 31.46s =========== 281s + echo 'rdjoqkol test state = true' 281s + for TEST_SUBSET in $modpath/tests/* 281s + echo /usr/lib/python3/dist-packages/pandas/tests/config 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.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/config 281s rdjoqkol test state = true 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)) 282s ============================= test session starts ============================== 282s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 282s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 282s rootdir: /usr/lib/python3/dist-packages/pandas 282s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 282s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 282s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 282s collected 50 items 282s 282s ../../../usr/lib/python3/dist-packages/pandas/tests/config/test_config.py ..................... 282s ../../../usr/lib/python3/dist-packages/pandas/tests/config/test_localization.py ............................. 282s 282s =============================== warnings summary =============================== 282s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 282s /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-4xqas1yc' 282s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 282s 282s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 282s /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-1g41spqa' 282s session.config.cache.set(STEPWISE_CACHE_DIR, []) 282s 282s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 282s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 282s ============================= slowest 30 durations ============================= 282s 0.01s call tests/config/test_localization.py::test_get_locales_prefix 282s 282s (29 durations < 0.005s hidden. Use -vv to show these durations.) 282s ======================== 50 passed, 2 warnings in 0.45s ======================== 282s rdjoqkol test state = true 282s + echo 'rdjoqkol test state = true' 282s + for TEST_SUBSET in $modpath/tests/* 282s + echo /usr/lib/python3/dist-packages/pandas/tests/construction 282s + grep -q -e __pycache__ 282s + PANDAS_CI=1 282s + LC_ALL=C.UTF-8 282s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/construction 283s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 283s 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" 283s 283s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 283s ============================= test session starts ============================== 283s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 283s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 283s rootdir: /usr/lib/python3/dist-packages/pandas 283s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 283s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 283s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 283s collected 1 item 283s 283s ../../../usr/lib/python3/dist-packages/pandas/tests/construction/test_extract_array.py . 283s 283s =============================== warnings summary =============================== 283s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 283s /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-fkj8cikp' 283s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 283s 283s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 283s /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-mdhzp2a2' 283s session.config.cache.set(STEPWISE_CACHE_DIR, []) 283s 283s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 283s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 283s ============================= slowest 30 durations ============================= 283s 283s (3 durations < 0.005s hidden. Use -vv to show these durations.) 283s ======================== 1 passed, 2 warnings in 0.07s ========================= 283s + echo 'rdjoqkol test state = true' 283s + for TEST_SUBSET in $modpath/tests/* 283s + echo /usr/lib/python3/dist-packages/pandas/tests/copy_view 283s + grep -q -e __pycache__ 283s + PANDAS_CI=1 283s + LC_ALL=C.UTF-8 283s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/copy_view 283s rdjoqkol test state = true 283s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 283s 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" 283s 283s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 284s ============================= test session starts ============================== 284s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 284s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 284s rootdir: /usr/lib/python3/dist-packages/pandas 284s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 284s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 284s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 284s collected 793 items 284s 284s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/index/test_datetimeindex.py ...... 284s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/index/test_index.py ..................... 284s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/index/test_periodindex.py .. 284s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/index/test_timedeltaindex.py .. 284s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_array.py ............. 284s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_astype.py .....ss...s..........s.. 284s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_chained_assignment_deprecation.py ............... 284s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_clip.py ...... 284s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_constructors.py ............................................................................ 284s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_core_functionalities.py ....... 285s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_functions.py .................... 285s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_indexing.py ....................................................................................s.....s........................................................................................................................................ 285s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_internals.py ..................... 285s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_interp_fillna.py ...................................................... 285s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_methods.py ........................................................................................................................................................................................................................................................ 285s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_replace.py ........................................ 285s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_setitem.py ......... 285s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_util.py .. 285s 285s =============================== warnings summary =============================== 285s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 285s /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-4beh0km0' 285s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 285s 285s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 285s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-i_psyrhc' 285s session.config.cache.set(STEPWISE_CACHE_DIR, []) 285s 285s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 285s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 285s ============================= slowest 30 durations ============================= 285s 0.01s call tests/copy_view/test_internals.py::test_exponential_backoff 285s 285s (29 durations < 0.005s hidden. Use -vv to show these durations.) 285s ================== 787 passed, 6 skipped, 2 warnings in 1.86s ================== 285s rdjoqkol test state = true 285s + echo 'rdjoqkol test state = true' 285s + for TEST_SUBSET in $modpath/tests/* 285s + echo /usr/lib/python3/dist-packages/pandas/tests/dtypes 285s + grep -q -e __pycache__ 285s + PANDAS_CI=1 285s + LC_ALL=C.UTF-8 285s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/dtypes 286s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 286s 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" 286s 286s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 287s ============================= test session starts ============================== 287s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 287s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 287s rootdir: /usr/lib/python3/dist-packages/pandas 287s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 287s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 287s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 287s collected 5628 items 287s 287s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_can_hold_element.py ........... 287s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_construct_from_scalar.py .... 287s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_construct_ndarray.py ....... 287s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_construct_object_arr.py ....................................... 287s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_dict_compat.py . 287s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_downcast.py ................................... 287s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_find_common_type.py .......................................................................................... 287s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_infer_datetimelike.py ... 287s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_infer_dtype.py .................................................................... 287s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_maybe_box_native.py ................ 289s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_promote.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 290s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_common.py .............................................................................................................................................................................s...................................................................................................................................................................................................................................................................... 290s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_concat.py .... 290s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_dtypes.py ........................................................................................................................................................................................................................................................................................... 290s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_generic.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 291s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_inference.py .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ssssssss....................................................... 291s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_missing.py ..........................................................................................................xxxx............................................................................................................................................................................................................. 291s 291s =============================== warnings summary =============================== 291s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 291s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-ziz67u2d' 291s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 291s 291s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 291s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-u06lpwhx' 291s session.config.cache.set(STEPWISE_CACHE_DIR, []) 291s 291s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 291s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 291s ============================= slowest 30 durations ============================= 291s 0.06s call tests/dtypes/test_common.py::test_is_sparse[True] 291s 0.05s call tests/dtypes/test_inference.py::TestInference::test_maybe_convert_objects_mixed_datetimes 291s 0.02s teardown tests/dtypes/test_missing.py::TestIsValidNAForDtype::test_is_valid_na_for_dtype_categorical 291s 291s (27 durations < 0.005s hidden. Use -vv to show these durations.) 291s ============ 5615 passed, 9 skipped, 4 xfailed, 2 warnings in 5.23s ============ 291s rdjoqkol test state = true 291s + echo 'rdjoqkol test state = true' 291s + for TEST_SUBSET in $modpath/tests/* 291s + echo /usr/lib/python3/dist-packages/pandas/tests/extension 291s + grep -q -e __pycache__ 291s + PANDAS_CI=1 291s + LC_ALL=C.UTF-8 291s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/extension 292s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 292s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 292s 292s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 294s ============================= test session starts ============================== 294s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 294s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 294s rootdir: /usr/lib/python3/dist-packages/pandas 294s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 294s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 294s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 294s collected 16808 items / 1 skipped 294s 295s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/array_with_attr/test_array_with_attr.py . 297s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/decimal/test_decimal.py ssssssssssssssssssssssssssssssssssss....................................x.................................................................................................................................................................................................................................................................................................................................xx............................................................s............................xxxxxxxxss..............xxssxxss................................................xxx..................... 307s ../../../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. 307s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/list/test_list.py . 308s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_categorical.py ssssssssssssssssssssssssssssssssssss....................................x..................................................................................................ssssssssssssssssssssssss...................................s.........................................................................................................................ss.................................................................................................xx...........................................................s............x..sxx................x.............xxxxxssssssssssssssssssssssssssssssssssss.. 308s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_common.py ............ 309s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_datetime.py ........................ssss............................................x..............................................................................................ssssssssssssssssssssssss.................................................................s......................................................................................................................................................................................xx..............................................xx...........................................................s............................................ssss......... 309s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_extension.py .............. 310s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_interval.py ssssssssssssssssssssssssssssssssssss....................................x..................................................................................................ssssssssssssssssssssssss.................................................................s...............................................................................................................................ss......................................................xx..............................................xx............................................................s............x. 322s ../../../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 326s ../../../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.. 328s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_period.py ..........................................ssss........ssss.....................................................................................x...x..................................................................................................................................................................................................ssssssssssssssssssssssssssssssssssssssssssssssss..................................................................................................................................ss........................................................................................................................................................................................................................................................................................................................................................................................................................................................................xxxx.......................................................................................................................s.s............................................................................ssss........ssss................ 335s ../../../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. 339s ../../../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 339s 339s =============================== warnings summary =============================== 339s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 339s /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-clzqrowb' 339s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 339s 339s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 339s /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-4df8uh4v' 339s session.config.cache.set(STEPWISE_CACHE_DIR, []) 339s 339s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 339s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 339s ============================= slowest 30 durations ============================= 339s 0.08s call tests/extension/test_masked.py::TestMaskedArrays::test_setitem_loc_scalar_mixed[Int16Dtype] 339s 0.07s call tests/extension/decimal/test_decimal.py::TestDecimalArray::test_arith_series_with_array[__rpow__] 339s 0.07s call tests/extension/json/test_json.py::TestJSONArray::test_unary_ufunc_dunder_equivalence[negative] 339s 0.05s teardown tests/extension/test_string.py::test_searchsorted_with_na_raises[False-False-pyarrow_numpy] 339s 0.04s call tests/extension/decimal/test_decimal.py::TestDecimalArray::test_arith_series_with_array[__pow__] 339s 0.04s call tests/extension/decimal/test_decimal.py::TestDecimalArray::test_arith_frame_with_scalar[__rpow__] 339s 0.04s call tests/extension/decimal/test_decimal.py::TestDecimalArray::test_arith_series_with_scalar[__rpow__] 339s 0.04s call tests/extension/decimal/test_decimal.py::TestDecimalArray::test_arith_series_with_scalar[__pow__] 339s 0.04s call tests/extension/decimal/test_decimal.py::TestDecimalArray::test_arith_frame_with_scalar[__pow__] 339s 0.04s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[0-series-index2] 339s 0.03s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[nan-series-index2] 339s 0.03s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[0-series-index3] 339s 0.03s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[nan-series-index3] 339s 0.03s call tests/extension/test_interval.py::TestIntervalArray::test_unstack[series-index2] 339s 0.03s call tests/extension/test_interval.py::TestIntervalArray::test_unstack[frame-index2] 339s 0.03s call tests/extension/test_string.py::TestStringArray::test_unstack[False-python-series-index2] 339s 0.03s call tests/extension/test_interval.py::TestIntervalArray::test_unstack[series-index3] 339s 0.03s call tests/extension/test_string.py::TestStringArray::test_unstack[True-python-series-index2] 339s 0.03s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Int64Dtype-series-index2] 339s 0.03s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Int32Dtype-series-index2] 339s 0.03s call tests/extension/decimal/test_decimal.py::TestDecimalArray::test_unstack[series-index2] 339s 0.03s call tests/extension/test_numpy.py::TestNumpyExtensionArray::test_unstack[float-series-index2] 339s 0.03s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[BooleanDtype-series-index2] 339s 0.03s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Int8Dtype-series-index2] 339s 0.03s call tests/extension/test_numpy.py::TestNumpyExtensionArray::test_unstack[object-series-index2] 339s 0.03s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Float64Dtype-series-index2] 339s 0.03s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Float32Dtype-series-index2] 339s 0.03s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[UInt8Dtype-series-index2] 339s 0.03s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Int16Dtype-series-index2] 339s 0.03s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[UInt16Dtype-series-index2] 339s ======== 12106 passed, 4371 skipped, 332 xfailed, 2 warnings in 46.74s ========= 339s rdjoqkol test state = true 339s + echo 'rdjoqkol test state = true' 339s + for TEST_SUBSET in $modpath/tests/* 339s + echo /usr/lib/python3/dist-packages/pandas/tests/frame 339s + grep -q -e __pycache__ 339s + PANDAS_CI=1 339s + LC_ALL=C.UTF-8 339s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/frame 339s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 339s 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" 339s 339s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 343s ============================= test session starts ============================== 343s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 343s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 343s rootdir: /usr/lib/python3/dist-packages/pandas 343s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 343s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 343s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 343s collected 11172 items / 433 deselected / 1 skipped / 10739 selected 343s 344s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/constructors/test_from_dict.py .............. 344s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/constructors/test_from_records.py .s......................... 344s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_coercion.py .......x.x. 344s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_delitem.py .... 344s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_get.py .... 344s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_get_value.py .. 344s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_getitem.py ........................................ 345s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_indexing.py ...................................................................................................................................................................................................................................sss................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 345s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_insert.py ....... 345s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_mask.py ........... 345s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_set_value.py ... 345s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_setitem.py ........................................................................................................s..........................................................................................xxx...........................x..x..x..x........ 345s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_take.py .... 347s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_where.py ............................................................................................................................................. 347s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_xs.py .............................. 347s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_add_prefix_suffix.py ... 348s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_align.py ........................................................................................................................................................................................................................................................................................................................................................................................................................ 348s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_asfreq.py ........................................ 348s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_asof.py ........... 348s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_assign.py ..... 348s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_astype.py .......................................................................................................................s....s........................................................................................................ss.....ssssssssss 349s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_at_time.py ...................... 349s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_between_time.py .............................. 349s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_clip.py ..................... 349s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_combine.py ..... 349s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_combine_first.py ..................................s............................... 349s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_compare.py ......................... 349s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_convert_dtypes.py ..ssss..ssss.sss.. 349s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_copy.py ..... 349s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_count.py .. 349s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_cov_corr.py .............................................................s............ 350s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_describe.py ...............................................s 350s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_diff.py .............................................. 350s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_dot.py ................sss 350s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_drop.py ......................................................................... 350s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_drop_duplicates.py ..................................... 350s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_droplevel.py .. 350s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_dropna.py ................... 350s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_dtypes.py ........ 350s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_duplicated.py .......xxx........... 350s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_equals.py ... 350s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_explode.py ..................... 350s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_fillna.py ................................................................. 350s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_filter.py ........... 350s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_first_and_last.py ............. 350s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_first_valid_index.py ............... 350s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_get_numeric_data.py .... 351s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_head_tail.py .................................................................. 351s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_infer_objects.py . 352s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_info.py ..........................x......s...... 352s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_interpolate.py ...................................................................ssssssssss 352s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_is_homogeneous_dtype.py ....... 352s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_isetitem.py ... 352s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_isin.py ................. 352s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_iterrows.py . 352s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_join.py ...........s................... 352s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_map.py ......................... 352s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_matmul.py .. 352s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_nlargest.py .........................................................................................................................................................................................................................................................X.....X.....X.....X.......X..... 352s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_pct_change.py ............................. 352s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_pipe.py ...... 352s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_pop.py ... 354s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_quantile.py ........................................................................xx..........xx..........xx..........xx.................. 357s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_rank.py .........................................................................................................................ss 357s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_reindex.py ................................................................................................................................................. 357s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_reindex_like.py ..... 357s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_rename.py ......................... 357s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_rename_axis.py ......... 357s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_reorder_levels.py ... 358s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_replace.py ...................ss.................ssss....ssss................................................................................................................................................................. 358s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_reset_index.py ................................................................................................................................ 358s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_round.py ......... 358s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_sample.py .......................................................... 358s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_select_dtypes.py ..................................s...... 358s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_set_axis.py .............. 359s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_set_index.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 362s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_shift.py ...................................................................................x.x.x.x.x.xxxx........ 362s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_size.py ..... 362s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_sort_index.py ................................................................. 362s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_sort_values.py ...................................................X...............................XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX..... 362s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_swapaxes.py .... 362s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_swaplevel.py . 364s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_csv.py ............................................................................. 364s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_dict.py ...................................................................................................... 364s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_dict_of_blocks.py ... 364s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_numpy.py .... 364s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_period.py ...................................................................... 364s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_records.py ................................... 364s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_timestamp.py ...................................................................... 364s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_transpose.py ................... 364s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_truncate.py ........................................................................................ 364s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_tz_convert.py ........... 364s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_tz_localize.py ......... 364s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_update.py .............. 364s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_value_counts.py ................................. 364s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_values.py ............... 364s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_alter_axes.py .. 365s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_api.py ......................ss.......... 366s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_arithmetic.py ..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x..........x................................................................................................................................ 366s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_block_internals.py ................... 368s ../../../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................................ 368s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_cumulative.py ....... 368s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_iteration.py .................... 368s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_logical_ops.py ................. 368s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_nonunique_indexes.py ................ 368s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_npfuncs.py .... 369s ../../../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. 372s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_reductions.py ....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s....................................................................................................x.............x............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 372s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_repr.py ..........................................ssss................ 376s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_stack_unstack.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 376s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_subclass.py .................................................... 377s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_ufunc.py ....xx.........xxxxxxxx.xx....s. 377s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_unary.py .................. 377s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_validate.py ............................ 377s 377s =============================== warnings summary =============================== 377s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 377s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-r7nxj1an' 377s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 377s 377s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 377s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-zrnwic75' 377s session.config.cache.set(STEPWISE_CACHE_DIR, []) 377s 377s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 377s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 377s ============================= slowest 30 durations ============================= 377s 2.45s call tests/frame/methods/test_rank.py::TestRank::test_pct_max_many_rows 377s 1.34s call tests/frame/indexing/test_where.py::test_where_inplace_casting 377s 0.48s call tests/frame/test_api.py::TestDataFrameMisc::test_inspect_getmembers 377s 0.32s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_chunking[10000] 377s 0.31s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_chunking[50000] 377s 0.31s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_chunking[100000] 377s 0.23s call tests/frame/methods/test_cov_corr.py::TestDataFrameCorr::test_corr_scipy_method[kendall] 377s 0.22s call tests/frame/methods/test_info.py::test_info_verbose_with_counts_spacing[10001- # Column Non-Null Count Dtype ---- ------ -------------- ----- - 0 0 3 non-null float64- 10000 10000 3 non-null float64] 377s 0.20s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_with_dst_transitions_with_pickle 377s 0.12s call tests/frame/methods/test_cov_corr.py::TestDataFrameCorrWith::test_corrwith[Float64] 377s 0.11s call tests/frame/methods/test_info.py::test_info_verbose_check_header_separator_body 377s 0.11s call tests/frame/test_reductions.py::test_numeric_ea_axis_1[False-UInt16-2-std] 377s 0.10s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_dups_cols 377s 0.09s call tests/frame/methods/test_at_time.py::TestAtTime::test_at_time_axis[index] 377s 0.09s call tests/frame/methods/test_at_time.py::TestAtTime::test_at_time_axis[0] 377s 0.09s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack[False] 377s 0.07s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack_order_with_unsorted_levels_multi_row[False] 377s 0.07s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack[True] 377s 0.06s call tests/frame/test_repr.py::TestDataFrameRepr::test_repr_bytes_61_lines 377s 0.06s call tests/frame/test_repr.py::TestDataFrameRepr::test_repr_to_string 377s 0.06s call tests/frame/methods/test_interpolate.py::TestDataFrameInterpolate::test_interp_string_axis[index-0] 377s 0.06s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack_unstack_multiple[False] 377s 0.05s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack_order_with_unsorted_levels_multi_row[True] 377s 0.05s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack_unstack_multiple[True] 377s 0.05s call tests/frame/methods/test_interpolate.py::TestDataFrameInterpolate::test_interp_string_axis[columns-1] 377s 0.05s teardown tests/frame/test_validate.py::TestDataFrameValidate::test_validate_bool_args[5.0-sort_values] 377s 0.04s call tests/frame/test_iteration.py::TestIteration::test_itertuples_py2_3_field_limit_namedtuple[True-1024] 377s 0.04s call tests/frame/test_iteration.py::TestIteration::test_itertuples_py2_3_field_limit_namedtuple[False-1024] 377s 0.04s call tests/frame/methods/test_duplicated.py::test_duplicated_implemented_no_recursion 377s 0.04s call tests/frame/test_query_eval.py::TestDataFrameQueryNumExprPandas::test_nested_scope 377s = 10437 passed, 207 skipped, 433 deselected, 58 xfailed, 38 xpassed, 2 warnings in 37.44s = 377s + echo 'rdjoqkol test state = true' 377s + for TEST_SUBSET in $modpath/tests/* 377s + echo /usr/lib/python3/dist-packages/pandas/tests/generic 377s + grep -q -e __pycache__ 377s + PANDAS_CI=1 377s + LC_ALL=C.UTF-8 377s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/generic 377s rdjoqkol test state = true 378s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 378s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 378s 378s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 378s ============================= test session starts ============================== 378s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 378s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 378s rootdir: /usr/lib/python3/dist-packages/pandas 378s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 378s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 378s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 378s collected 1249 items 378s 378s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_duplicate_labels.py ..........xx...........x.......xx.xxx................x................ 381s ../../../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. 381s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_frame.py ............... 381s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_generic.py ................................................................................. 381s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_label_or_level_utils.py ....................................................................... 381s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_series.py ................... 381s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py expected 381s bar a b c d e f g h 381s foo 381s pandas_0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 381s pandas_1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 381s pandas_2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 381s pandas_3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 381s Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='object', name='foo') 381s bar 381s a object 381s b int64 381s c uint8 381s d float64 381s e bool 381s f category 381s g datetime64[ns] 381s h datetime64[ns, US/Eastern] 381s dtype: object 381s actual 381s Size: 236B 381s Dimensions: (foo: 4) 381s Coordinates: 381s * foo (foo) object 32B 'pandas_0' 'pandas_1' 'pandas_2' 'pandas_3' 381s Data variables: 381s a (foo) object 32B 'a' 'b' 'c' 'd' 381s b (foo) int64 32B 1 2 3 4 381s c (foo) uint8 4B 3 4 5 6 381s d (foo) float64 32B 4.0 5.0 6.0 7.0 381s e (foo) bool 4B True False True False 381s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 381s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 381s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 381s a b c d e f g h 381s foo 381s pandas_0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 381s pandas_1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 381s pandas_2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 381s pandas_3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 381s Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='object', name='foo') 381s a object 381s b int64 381s c uint8 381s d float64 381s e bool 381s f category 381s g datetime64[ns] 381s h datetime64[ns, US/Eastern] 381s dtype: object 381s Xexpected 381s bar a b c d e f g h 381s foo 381s 2020-01-01 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 381s 2020-01-02 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 381s 2020-01-03 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 381s 2020-01-04 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 381s DatetimeIndex(['2020-01-01', '2020-01-02', '2020-01-03', '2020-01-04'], dtype='datetime64[ns]', name='foo', freq='D') 381s bar 381s a object 381s b int64 381s c uint8 381s d float64 381s e bool 381s f category 381s g datetime64[ns] 381s h datetime64[ns, US/Eastern] 381s dtype: object 381s actual 381s Size: 236B 381s Dimensions: (foo: 4) 381s Coordinates: 381s * foo (foo) datetime64[ns] 32B 2020-01-01 2020-01-02 ... 2020-01-04 381s Data variables: 381s a (foo) object 32B 'a' 'b' 'c' 'd' 381s b (foo) int64 32B 1 2 3 4 381s c (foo) uint8 4B 3 4 5 6 381s d (foo) float64 32B 4.0 5.0 6.0 7.0 381s e (foo) bool 4B True False True False 381s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 381s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 381s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 381s a b c d e f g h 381s foo 381s 2020-01-01 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 381s 2020-01-02 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 381s 2020-01-03 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 381s 2020-01-04 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 381s DatetimeIndex(['2020-01-01', '2020-01-02', '2020-01-03', '2020-01-04'], dtype='datetime64[ns]', name='foo', freq='D') 381s a object 381s b int64 381s c uint8 381s d float64 381s e bool 381s f category 381s g datetime64[ns] 381s h datetime64[ns, US/Eastern] 381s dtype: object 381s Xexpected 381s bar a b c ... f g h 381s foo ... 381s 2020-01-01 00:00:00-08:00 a 1 3 ... a 2013-01-01 2013-01-01 00:00:00-05:00 381s 2020-01-02 00:00:00-08:00 b 2 4 ... b 2013-01-02 2013-01-02 00:00:00-05:00 381s 2020-01-03 00:00:00-08:00 c 3 5 ... c 2013-01-03 2013-01-03 00:00:00-05:00 381s 2020-01-04 00:00:00-08:00 d 4 6 ... d 2013-01-04 2013-01-04 00:00:00-05:00 381s 381s [4 rows x 8 columns] 381s DatetimeIndex(['2020-01-01 00:00:00-08:00', '2020-01-02 00:00:00-08:00', 381s '2020-01-03 00:00:00-08:00', '2020-01-04 00:00:00-08:00'], 381s dtype='datetime64[ns, US/Pacific]', name='foo', freq='D') 381s bar 381s a object 381s b int64 381s c uint8 381s d float64 381s e bool 381s f category 381s g datetime64[ns] 381s h datetime64[ns, US/Eastern] 381s dtype: object 381s actual 381s Size: 236B 381s Dimensions: (foo: 4) 381s Coordinates: 381s * foo (foo) object 32B 1577865600000000000 ... 1578124800000000000 381s Data variables: 381s a (foo) object 32B 'a' 'b' 'c' 'd' 381s b (foo) int64 32B 1 2 3 4 381s c (foo) uint8 4B 3 4 5 6 381s d (foo) float64 32B 4.0 5.0 6.0 7.0 381s e (foo) bool 4B True False True False 381s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 381s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 381s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 381s a b c ... f g h 381s foo ... 381s 2020-01-01 00:00:00-08:00 a 1 3 ... NaN 2013-01-01 2013-01-01 00:00:00-05:00 381s 2020-01-02 00:00:00-08:00 b 2 4 ... NaN 2013-01-02 2013-01-02 00:00:00-05:00 381s 2020-01-03 00:00:00-08:00 c 3 5 ... NaN 2013-01-03 2013-01-03 00:00:00-05:00 381s 2020-01-04 00:00:00-08:00 d 4 6 ... NaN 2013-01-04 2013-01-04 00:00:00-05:00 381s 381s [4 rows x 8 columns] 381s Index([2020-01-01 00:00:00-08:00, 2020-01-02 00:00:00-08:00, 381s 2020-01-03 00:00:00-08:00, 2020-01-04 00:00:00-08:00], 381s dtype='object', name='foo') 381s a object 381s b int64 381s c uint8 381s d float64 381s e bool 381s f category 381s g datetime64[ns] 381s h datetime64[ns, US/Eastern] 381s dtype: object 381s xexpected 381s bar a b c d e f g h 381s foo 381s 2020-01-01 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 381s 2020-01-02 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 381s 2020-01-03 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 381s 2020-01-04 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 381s PeriodIndex(['2020-01-01', '2020-01-02', '2020-01-03', '2020-01-04'], dtype='period[D]', name='foo') 381s bar 381s a object 381s b int64 381s c uint8 381s d float64 381s e bool 381s f category 381s g datetime64[ns] 381s h datetime64[ns, US/Eastern] 381s dtype: object 381s actual 381s Size: 236B 381s Dimensions: (foo: 4) 381s Coordinates: 381s * foo (foo) object 32B 2020-01-01 2020-01-02 2020-01-03 2020-01-04 381s Data variables: 381s a (foo) object 32B 'a' 'b' 'c' 'd' 381s b (foo) int64 32B 1 2 3 4 381s c (foo) uint8 4B 3 4 5 6 381s d (foo) float64 32B 4.0 5.0 6.0 7.0 381s e (foo) bool 4B True False True False 381s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 381s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 381s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 381s a b c d e f g h 381s foo 381s 2020-01-01 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 381s 2020-01-02 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 381s 2020-01-03 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 381s 2020-01-04 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 381s PeriodIndex(['2020-01-01', '2020-01-02', '2020-01-03', '2020-01-04'], dtype='period[D]', name='foo') 381s a object 381s b int64 381s c uint8 381s d float64 381s e bool 381s f category 381s g datetime64[ns] 381s h datetime64[ns, US/Eastern] 381s dtype: object 381s Xexpected 381s bar a b c d e f g h 381s foo 381s 1 days a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 381s 2 days b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 381s 3 days c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 381s 4 days d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 381s TimedeltaIndex(['1 days', '2 days', '3 days', '4 days'], dtype='timedelta64[ns]', name='foo', freq='D') 381s bar 381s a object 381s b int64 381s c uint8 381s d float64 381s e bool 381s f category 381s g datetime64[ns] 381s h datetime64[ns, US/Eastern] 381s dtype: object 381s actual 381s Size: 236B 381s Dimensions: (foo: 4) 381s Coordinates: 381s * foo (foo) timedelta64[ns] 32B 1 days 2 days 3 days 4 days 381s Data variables: 381s a (foo) object 32B 'a' 'b' 'c' 'd' 381s b (foo) int64 32B 1 2 3 4 381s c (foo) uint8 4B 3 4 5 6 381s d (foo) float64 32B 4.0 5.0 6.0 7.0 381s e (foo) bool 4B True False True False 381s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 381s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 381s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 381s a b c d e f g h 381s foo 381s 1 days a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 381s 2 days b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 381s 3 days c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 381s 4 days d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 381s TimedeltaIndex(['1 days', '2 days', '3 days', '4 days'], dtype='timedelta64[ns]', name='foo', freq='D') 381s a object 381s b int64 381s c uint8 381s d float64 381s e bool 381s f category 381s g datetime64[ns] 381s h datetime64[ns, US/Eastern] 381s dtype: object 381s Xexpected 381s bar a b c d e f g h 381s foo 381s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 381s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 381s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 381s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 381s RangeIndex(start=0, stop=4, step=1, name='foo') 381s bar 381s a object 381s b int64 381s c uint8 381s d float64 381s e bool 381s f category 381s g datetime64[ns] 381s h datetime64[ns, US/Eastern] 381s dtype: object 381s actual 381s Size: 236B 381s Dimensions: (foo: 4) 381s Coordinates: 381s * foo (foo) int64 32B 0 1 2 3 381s Data variables: 381s a (foo) object 32B 'a' 'b' 'c' 'd' 381s b (foo) int64 32B 1 2 3 4 381s c (foo) uint8 4B 3 4 5 6 381s d (foo) float64 32B 4.0 5.0 6.0 7.0 381s e (foo) bool 4B True False True False 381s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 381s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 381s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 381s a b c d e f g h 381s foo 381s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 381s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 381s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 381s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 381s RangeIndex(start=0, stop=4, step=1, name='foo') 381s a object 381s b int64 381s c uint8 381s d float64 381s e bool 381s f category 381s g datetime64[ns] 381s h datetime64[ns, US/Eastern] 381s dtype: object 381s Xexpected 381s bar a b c d e f g h 381s foo 381s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 381s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 381s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 381s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 381s Index([0, 1, 2, 3], dtype='int8', name='foo') 381s bar 381s a object 381s b int64 381s c uint8 381s d float64 381s e bool 381s f category 381s g datetime64[ns] 381s h datetime64[ns, US/Eastern] 381s dtype: object 381s actual 381s Size: 208B 381s Dimensions: (foo: 4) 381s Coordinates: 381s * foo (foo) int8 4B 0 1 2 3 381s Data variables: 381s a (foo) object 32B 'a' 'b' 'c' 'd' 381s b (foo) int64 32B 1 2 3 4 381s c (foo) uint8 4B 3 4 5 6 381s d (foo) float64 32B 4.0 5.0 6.0 7.0 381s e (foo) bool 4B True False True False 381s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 381s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 381s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 381s a b c d e f g h 381s foo 381s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 381s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 381s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 381s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 381s Index([0, 1, 2, 3], dtype='int8', name='foo') 381s a object 381s b int64 381s c uint8 381s d float64 381s e bool 381s f category 381s g datetime64[ns] 381s h datetime64[ns, US/Eastern] 381s dtype: object 381s Xexpected 381s bar a b c d e f g h 381s foo 381s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 381s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 381s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 381s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 381s Index([0, 1, 2, 3], dtype='int16', name='foo') 381s bar 381s a object 381s b int64 381s c uint8 381s d float64 381s e bool 381s f category 381s g datetime64[ns] 381s h datetime64[ns, US/Eastern] 381s dtype: object 381s actual 381s Size: 212B 381s Dimensions: (foo: 4) 381s Coordinates: 381s * foo (foo) int16 8B 0 1 2 3 381s Data variables: 381s a (foo) object 32B 'a' 'b' 'c' 'd' 381s b (foo) int64 32B 1 2 3 4 381s c (foo) uint8 4B 3 4 5 6 381s d (foo) float64 32B 4.0 5.0 6.0 7.0 381s e (foo) bool 4B True False True False 381s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 381s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 381s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 381s a b c d e f g h 381s foo 381s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 381s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 381s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 381s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 381s Index([0, 1, 2, 3], dtype='int16', name='foo') 381s a object 381s b int64 381s c uint8 381s d float64 381s e bool 381s f category 381s g datetime64[ns] 381s h datetime64[ns, US/Eastern] 381s dtype: object 381s Xexpected 381s bar a b c d e f g h 381s foo 381s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 381s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 381s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 381s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 381s Index([0, 1, 2, 3], dtype='int32', name='foo') 381s bar 381s a object 381s b int64 381s c uint8 381s d float64 381s e bool 381s f category 381s g datetime64[ns] 381s h datetime64[ns, US/Eastern] 381s dtype: object 381s actual 381s Size: 220B 381s Dimensions: (foo: 4) 381s Coordinates: 381s * foo (foo) int32 16B 0 1 2 3 381s Data variables: 381s a (foo) object 32B 'a' 'b' 'c' 'd' 381s b (foo) int64 32B 1 2 3 4 381s c (foo) uint8 4B 3 4 5 6 381s d (foo) float64 32B 4.0 5.0 6.0 7.0 381s e (foo) bool 4B True False True False 381s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 381s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 381s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 381s a b c d e f g h 381s foo 381s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 381s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 381s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 381s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 381s Index([0, 1, 2, 3], dtype='int32', name='foo') 381s a object 381s b int64 381s c uint8 381s d float64 381s e bool 381s f category 381s g datetime64[ns] 381s h datetime64[ns, US/Eastern] 381s dtype: object 381s Xexpected 381s bar a b c d e f g h 381s foo 381s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 381s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 381s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 381s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 381s Index([0, 1, 2, 3], dtype='int64', name='foo') 381s bar 381s a object 381s b int64 381s c uint8 381s d float64 381s e bool 381s f category 381s g datetime64[ns] 381s h datetime64[ns, US/Eastern] 381s dtype: object 381s actual 381s Size: 236B 381s Dimensions: (foo: 4) 381s Coordinates: 381s * foo (foo) int64 32B 0 1 2 3 381s Data variables: 381s a (foo) object 32B 'a' 'b' 'c' 'd' 381s b (foo) int64 32B 1 2 3 4 381s c (foo) uint8 4B 3 4 5 6 381s d (foo) float64 32B 4.0 5.0 6.0 7.0 381s e (foo) bool 4B True False True False 381s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 381s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 381s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 381s a b c d e f g h 381s foo 381s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 381s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 381s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 381s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 381s Index([0, 1, 2, 3], dtype='int64', name='foo') 381s a object 381s b int64 381s c uint8 381s d float64 381s e bool 381s f category 381s g datetime64[ns] 381s h datetime64[ns, US/Eastern] 381s dtype: object 381s Xexpected 381s bar a b c d e f g h 381s foo 381s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 381s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 381s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 381s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 381s Index([0, 1, 2, 3], dtype='uint8', name='foo') 381s bar 381s a object 381s b int64 381s c uint8 381s d float64 381s e bool 381s f category 381s g datetime64[ns] 381s h datetime64[ns, US/Eastern] 381s dtype: object 381s actual 381s Size: 208B 381s Dimensions: (foo: 4) 381s Coordinates: 381s * foo (foo) uint8 4B 0 1 2 3 381s Data variables: 381s a (foo) object 32B 'a' 'b' 'c' 'd' 381s b (foo) int64 32B 1 2 3 4 381s c (foo) uint8 4B 3 4 5 6 381s d (foo) float64 32B 4.0 5.0 6.0 7.0 381s e (foo) bool 4B True False True False 381s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 381s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 381s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 381s a b c d e f g h 381s foo 381s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 381s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 381s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 381s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 381s Index([0, 1, 2, 3], dtype='uint8', name='foo') 381s a object 381s b int64 381s c uint8 381s d float64 381s e bool 381s f category 381s g datetime64[ns] 381s h datetime64[ns, US/Eastern] 381s dtype: object 381s Xexpected 381s bar a b c d e f g h 381s foo 381s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 381s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 381s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 381s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 381s Index([0, 1, 2, 3], dtype='uint16', name='foo') 381s bar 381s a object 381s b int64 381s c uint8 381s d float64 381s e bool 381s f category 381s g datetime64[ns] 381s h datetime64[ns, US/Eastern] 381s dtype: object 381s actual 381s Size: 212B 381s Dimensions: (foo: 4) 381s Coordinates: 381s * foo (foo) uint16 8B 0 1 2 3 381s Data variables: 381s a (foo) object 32B 'a' 'b' 'c' 'd' 381s b (foo) int64 32B 1 2 3 4 381s c (foo) uint8 4B 3 4 5 6 381s d (foo) float64 32B 4.0 5.0 6.0 7.0 381s e (foo) bool 4B True False True False 381s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 381s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 381s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 381s a b c d e f g h 381s foo 381s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 381s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 381s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 381s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 381s Index([0, 1, 2, 3], dtype='uint16', name='foo') 381s a object 381s b int64 381s c uint8 381s d float64 381s e bool 381s f category 381s g datetime64[ns] 381s h datetime64[ns, US/Eastern] 381s dtype: object 382s Xexpected 382s bar a b c d e f g h 382s foo 382s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s Index([0, 1, 2, 3], dtype='uint32', name='foo') 382s bar 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s actual 382s Size: 220B 382s Dimensions: (foo: 4) 382s Coordinates: 382s * foo (foo) uint32 16B 0 1 2 3 382s Data variables: 382s a (foo) object 32B 'a' 'b' 'c' 'd' 382s b (foo) int64 32B 1 2 3 4 382s c (foo) uint8 4B 3 4 5 6 382s d (foo) float64 32B 4.0 5.0 6.0 7.0 382s e (foo) bool 4B True False True False 382s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 382s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 382s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 382s a b c d e f g h 382s foo 382s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s Index([0, 1, 2, 3], dtype='uint32', name='foo') 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s Xexpected 382s bar a b c d e f g h 382s foo 382s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s Index([0, 1, 2, 3], dtype='uint64', name='foo') 382s bar 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s actual 382s Size: 236B 382s Dimensions: (foo: 4) 382s Coordinates: 382s * foo (foo) uint64 32B 0 1 2 3 382s Data variables: 382s a (foo) object 32B 'a' 'b' 'c' 'd' 382s b (foo) int64 32B 1 2 3 4 382s c (foo) uint8 4B 3 4 5 6 382s d (foo) float64 32B 4.0 5.0 6.0 7.0 382s e (foo) bool 4B True False True False 382s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 382s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 382s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 382s a b c d e f g h 382s foo 382s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s Index([0, 1, 2, 3], dtype='uint64', name='foo') 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s Xexpected 382s bar a b c d e f g h 382s foo 382s 0.0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s 1.0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s 2.0 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s Index([0.0, 1.0, 2.0, 3.0], dtype='float32', name='foo') 382s bar 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s actual 382s Size: 220B 382s Dimensions: (foo: 4) 382s Coordinates: 382s * foo (foo) float32 16B 0.0 1.0 2.0 3.0 382s Data variables: 382s a (foo) object 32B 'a' 'b' 'c' 'd' 382s b (foo) int64 32B 1 2 3 4 382s c (foo) uint8 4B 3 4 5 6 382s d (foo) float64 32B 4.0 5.0 6.0 7.0 382s e (foo) bool 4B True False True False 382s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 382s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 382s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 382s a b c d e f g h 382s foo 382s 0.0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s 1.0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s 2.0 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s Index([0.0, 1.0, 2.0, 3.0], dtype='float32', name='foo') 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s Xexpected 382s bar a b c d e f g h 382s foo 382s 0.0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s 1.0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s 2.0 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s Index([0.0, 1.0, 2.0, 3.0], dtype='float64', name='foo') 382s bar 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s actual 382s Size: 236B 382s Dimensions: (foo: 4) 382s Coordinates: 382s * foo (foo) float64 32B 0.0 1.0 2.0 3.0 382s Data variables: 382s a (foo) object 32B 'a' 'b' 'c' 'd' 382s b (foo) int64 32B 1 2 3 4 382s c (foo) uint8 4B 3 4 5 6 382s d (foo) float64 32B 4.0 5.0 6.0 7.0 382s e (foo) bool 4B True False True False 382s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 382s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 382s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 382s a b c d e f g h 382s foo 382s 0.0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s 1.0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s 2.0 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s Index([0.0, 1.0, 2.0, 3.0], dtype='float64', name='foo') 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s Xexpected 382s bar a b c d e f g h 382s foo 382s True a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s False b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s True c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s Index([True, False, True, False], dtype='object', name='foo') 382s bar 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s actual 382s Size: 236B 382s Dimensions: (foo: 4) 382s Coordinates: 382s * foo (foo) object 32B True False True False 382s Data variables: 382s a (foo) object 32B 'a' 'b' 'c' 'd' 382s b (foo) int64 32B 1 2 3 4 382s c (foo) uint8 4B 3 4 5 6 382s d (foo) float64 32B 4.0 5.0 6.0 7.0 382s e (foo) bool 4B True False True False 382s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 382s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 382s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 382s a b c d e f g h 382s foo 382s True a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s True a 1 3 4.0 True c 2013-01-01 2013-01-01 00:00:00-05:00 382s False b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s False b 2 4 5.0 False d 2013-01-02 2013-01-02 00:00:00-05:00 382s True c 3 5 6.0 True a 2013-01-03 2013-01-03 00:00:00-05:00 382s True c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s False d 4 6 7.0 False b 2013-01-04 2013-01-04 00:00:00-05:00 382s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s Index([True, True, False, False, True, True, False, False], dtype='object', name='foo') 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s xexpected 382s bar a b c d e f g h 382s foo 382s True a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s False b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s True c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s Index([True, False, True, False], dtype='bool', name='foo') 382s bar 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s actual 382s Size: 208B 382s Dimensions: (foo: 4) 382s Coordinates: 382s * foo (foo) bool 4B True False True False 382s Data variables: 382s a (foo) object 32B 'a' 'b' 'c' 'd' 382s b (foo) int64 32B 1 2 3 4 382s c (foo) uint8 4B 3 4 5 6 382s d (foo) float64 32B 4.0 5.0 6.0 7.0 382s e (foo) bool 4B True False True False 382s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 382s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 382s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 382s a b c d e f g h 382s foo 382s True a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s True a 1 3 4.0 True c 2013-01-01 2013-01-01 00:00:00-05:00 382s False b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s False b 2 4 5.0 False d 2013-01-02 2013-01-02 00:00:00-05:00 382s True c 3 5 6.0 True a 2013-01-03 2013-01-03 00:00:00-05:00 382s True c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s False d 4 6 7.0 False b 2013-01-04 2013-01-04 00:00:00-05:00 382s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s Index([True, True, False, False, True, True, False, False], dtype='bool', name='foo') 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s xexpected 382s bar a b c d e f g h 382s foo 382s 0.0+0.0j a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s 1.0+1.0j b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s 2.0+2.0j c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s 3.0+3.0j d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s Index([0j, (1+1j), (2+2j), (3+3j)], dtype='complex64', name='foo') 382s bar 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s actual 382s Size: 236B 382s Dimensions: (foo: 4) 382s Coordinates: 382s * foo (foo) complex64 32B 0j (1+1j) (2+2j) (3+3j) 382s Data variables: 382s a (foo) object 32B 'a' 'b' 'c' 'd' 382s b (foo) int64 32B 1 2 3 4 382s c (foo) uint8 4B 3 4 5 6 382s d (foo) float64 32B 4.0 5.0 6.0 7.0 382s e (foo) bool 4B True False True False 382s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 382s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 382s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 382s a b c d e f g h 382s foo 382s 0.0+0.0j a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s 1.0+1.0j b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s 2.0+2.0j c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s 3.0+3.0j d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s Index([0j, (1+1j), (2+2j), (3+3j)], dtype='complex64', name='foo') 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s Xexpected 382s bar a b c d e f g h 382s foo 382s 0.0+0.0j a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s 1.0+1.0j b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s 2.0+2.0j c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s 3.0+3.0j d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s Index([0j, (1+1j), (2+2j), (3+3j)], dtype='complex128', name='foo') 382s bar 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s actual 382s Size: 268B 382s Dimensions: (foo: 4) 382s Coordinates: 382s * foo (foo) complex128 64B 0j (1+1j) (2+2j) (3+3j) 382s Data variables: 382s a (foo) object 32B 'a' 'b' 'c' 'd' 382s b (foo) int64 32B 1 2 3 4 382s c (foo) uint8 4B 3 4 5 6 382s d (foo) float64 32B 4.0 5.0 6.0 7.0 382s e (foo) bool 4B True False True False 382s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 382s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 382s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 382s a b c d e f g h 382s foo 382s 0.0+0.0j a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s 1.0+1.0j b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s 2.0+2.0j c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s 3.0+3.0j d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s Index([0j, (1+1j), (2+2j), (3+3j)], dtype='complex128', name='foo') 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s Xexpected 382s bar a b c d e f g h 382s foo 382s a a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s b b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s c c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s d d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s CategoricalIndex(['a', 'b', 'c', 'd'], categories=['a', 'b', 'c', 'd'], ordered=False, dtype='category', name='foo') 382s bar 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s actual 382s Size: 236B 382s Dimensions: (foo: 4) 382s Coordinates: 382s * foo (foo) object 32B 'a' 'b' 'c' 'd' 382s Data variables: 382s a (foo) object 32B 'a' 'b' 'c' 'd' 382s b (foo) int64 32B 1 2 3 4 382s c (foo) uint8 4B 3 4 5 6 382s d (foo) float64 32B 4.0 5.0 6.0 7.0 382s e (foo) bool 4B True False True False 382s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 382s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 382s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 382s a b c d e f g h 382s foo 382s a a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s b b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s c c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s d d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s Index(['a', 'b', 'c', 'd'], dtype='object', name='foo') 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s xexpected 382s bar a b c d e f g h 382s foo 382s (0.0, 1.0] a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s (1.0, 2.0] b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s (2.0, 3.0] c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s (3.0, 4.0] d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s IntervalIndex([(0.0, 1.0], (1.0, 2.0], (2.0, 3.0], (3.0, 4.0]], dtype='interval[float64, right]', name='foo') 382s bar 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s actual 382s Size: 236B 382s Dimensions: (foo: 4) 382s Coordinates: 382s * foo (foo) object 32B (0.0, 1.0] (1.0, 2.0] (2.0, 3.0] (3.0, 4.0] 382s Data variables: 382s a (foo) object 32B 'a' 'b' 'c' 'd' 382s b (foo) int64 32B 1 2 3 4 382s c (foo) uint8 4B 3 4 5 6 382s d (foo) float64 32B 4.0 5.0 6.0 7.0 382s e (foo) bool 4B True False True False 382s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 382s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 382s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 382s a b c d e f g h 382s foo 382s (0.0, 1.0] a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s (1.0, 2.0] b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s (2.0, 3.0] c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s (3.0, 4.0] d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s IntervalIndex([(0.0, 1.0], (1.0, 2.0], (2.0, 3.0], (3.0, 4.0]], dtype='interval[float64, right]', name='foo') 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s Xsexpected 382s bar a b c d e f g h 382s foo 382s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s 0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s 1 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s 1 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s Index([0, 0, 1, 1], dtype='int64', name='foo') 382s bar 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s actual 382s Size: 236B 382s Dimensions: (foo: 4) 382s Coordinates: 382s * foo (foo) int64 32B 0 0 1 1 382s Data variables: 382s a (foo) object 32B 'a' 'b' 'c' 'd' 382s b (foo) int64 32B 1 2 3 4 382s c (foo) uint8 4B 3 4 5 6 382s d (foo) float64 32B 4.0 5.0 6.0 7.0 382s e (foo) bool 4B True False True False 382s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 382s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 382s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 382s a b c d e f g h 382s foo 382s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s 0 a 1 3 4.0 True b 2013-01-01 2013-01-01 00:00:00-05:00 382s 0 b 2 4 5.0 False a 2013-01-02 2013-01-02 00:00:00-05:00 382s 0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s 1 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s 1 c 3 5 6.0 True d 2013-01-03 2013-01-03 00:00:00-05:00 382s 1 d 4 6 7.0 False c 2013-01-04 2013-01-04 00:00:00-05:00 382s 1 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s Index([0, 0, 0, 0, 1, 1, 1, 1], dtype='int64', name='foo') 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s xexpected 382s bar a b c d e f g h 382s foo 382s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s Index([0, 1, 2, 3], dtype='Int64', name='foo') 382s bar 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s actual 382s Size: 236B 382s Dimensions: (foo: 4) 382s Coordinates: 382s * foo (foo) object 32B 0 1 2 3 382s Data variables: 382s a (foo) object 32B 'a' 'b' 'c' 'd' 382s b (foo) int64 32B 1 2 3 4 382s c (foo) uint8 4B 3 4 5 6 382s d (foo) float64 32B 4.0 5.0 6.0 7.0 382s e (foo) bool 4B True False True False 382s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 382s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 382s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 382s a b c d e f g h 382s foo 382s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s Index([0, 1, 2, 3], dtype='object', name='foo') 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s xexpected 382s bar a b c d e f g h 382s foo 382s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s Index([0, 1, 2, 3], dtype='UInt16', name='foo') 382s bar 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s actual 382s Size: 236B 382s Dimensions: (foo: 4) 382s Coordinates: 382s * foo (foo) object 32B 0 1 2 3 382s Data variables: 382s a (foo) object 32B 'a' 'b' 'c' 'd' 382s b (foo) int64 32B 1 2 3 4 382s c (foo) uint8 4B 3 4 5 6 382s d (foo) float64 32B 4.0 5.0 6.0 7.0 382s e (foo) bool 4B True False True False 382s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 382s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 382s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 382s a b c d e f g h 382s foo 382s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s Index([0, 1, 2, 3], dtype='object', name='foo') 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s xexpected 382s bar a b c d e f g h 382s foo 382s 0.0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s 1.0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s 2.0 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s Index([0.0, 1.0, 2.0, 3.0], dtype='Float32', name='foo') 382s bar 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s actual 382s Size: 236B 382s Dimensions: (foo: 4) 382s Coordinates: 382s * foo (foo) object 32B 0.0 1.0 2.0 3.0 382s Data variables: 382s a (foo) object 32B 'a' 'b' 'c' 'd' 382s b (foo) int64 32B 1 2 3 4 382s c (foo) uint8 4B 3 4 5 6 382s d (foo) float64 32B 4.0 5.0 6.0 7.0 382s e (foo) bool 4B True False True False 382s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 382s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 382s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 382s a b c d e f g h 382s foo 382s 0.0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s 1.0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s 2.0 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s Index([0.0, 1.0, 2.0, 3.0], dtype='object', name='foo') 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s xexpected 382s bar a b c d e f g h 382s foo 382s False a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s True b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s True c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s True d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s Index([False, True, True, True], dtype='boolean', name='foo') 382s bar 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s actual 382s Size: 236B 382s Dimensions: (foo: 4) 382s Coordinates: 382s * foo (foo) object 32B False True True True 382s Data variables: 382s a (foo) object 32B 'a' 'b' 'c' 'd' 382s b (foo) int64 32B 1 2 3 4 382s c (foo) uint8 4B 3 4 5 6 382s d (foo) float64 32B 4.0 5.0 6.0 7.0 382s e (foo) bool 4B True False True False 382s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 382s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 382s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 382s a b c d e f g h 382s foo 382s False a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s True b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s True b 2 4 5.0 False c 2013-01-02 2013-01-02 00:00:00-05:00 382s True b 2 4 5.0 False d 2013-01-02 2013-01-02 00:00:00-05:00 382s True c 3 5 6.0 True b 2013-01-03 2013-01-03 00:00:00-05:00 382s True c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s True c 3 5 6.0 True d 2013-01-03 2013-01-03 00:00:00-05:00 382s True d 4 6 7.0 False b 2013-01-04 2013-01-04 00:00:00-05:00 382s True d 4 6 7.0 False c 2013-01-04 2013-01-04 00:00:00-05:00 382s True d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s Index([False, True, True, True, True, True, True, True, True, True], dtype='object', name='foo') 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s xexpected 382s bar a b c d e f g h 382s foo 382s pandas_0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s pandas_1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s pandas_2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s pandas_3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='string', name='foo') 382s bar 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s actual 382s Size: 236B 382s Dimensions: (foo: 4) 382s Coordinates: 382s * foo (foo) object 32B 'pandas_0' 'pandas_1' 'pandas_2' 'pandas_3' 382s Data variables: 382s a (foo) object 32B 'a' 'b' 'c' 'd' 382s b (foo) int64 32B 1 2 3 4 382s c (foo) uint8 4B 3 4 5 6 382s d (foo) float64 32B 4.0 5.0 6.0 7.0 382s e (foo) bool 4B True False True False 382s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 382s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 382s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 382s a b c d e f g h 382s foo 382s pandas_0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 382s pandas_1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 382s pandas_2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 382s pandas_3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 382s Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='object', name='foo') 382s a object 382s b int64 382s c uint8 382s d float64 382s e bool 382s f category 382s g datetime64[ns] 382s h datetime64[ns, US/Eastern] 382s dtype: object 382s x................................. 382s 382s =============================== warnings summary =============================== 382s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 382s /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-q1m50_pv' 382s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 382s 382s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 382s /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-cn608a00' 382s session.config.cache.set(STEPWISE_CACHE_DIR, []) 382s 382s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 382s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 382s ============================= slowest 30 durations ============================= 382s 0.21s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[string] 382s 0.03s call tests/generic/test_generic.py::TestGeneric::test_truncate_out_of_bounds[DataFrame] 382s 0.02s call tests/generic/test_generic.py::TestGeneric::test_truncate_out_of_bounds[Series] 382s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[float32] 382s 0.01s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[bool-object] 382s 0.01s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_bool] 382s 0.01s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[interval] 382s 0.01s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[datetime-tz] 382s 0.01s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[complex64] 382s 0.01s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[complex128] 382s 0.01s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[categorical] 382s 0.01s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[timedelta] 382s 0.01s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[period] 382s 0.01s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[repeats] 382s 0.01s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[float64] 382s 0.01s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[datetime] 382s 0.01s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[bool-dtype] 382s 0.01s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[int32] 382s 0.01s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_int] 382s 0.01s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_float] 382s 0.01s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[uint16] 382s 0.01s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[int8] 382s 0.01s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[uint64] 382s 0.01s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_uint] 382s 0.01s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[uint8] 382s 0.01s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[int64] 382s 0.01s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[int16] 382s 0.01s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[uint32] 382s 0.01s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[range] 382s 0.01s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[string-python] 382s ==== 978 passed, 105 skipped, 148 xfailed, 18 xpassed, 2 warnings in 4.14s ===== 382s rdjoqkol test state = true 382s + echo 'rdjoqkol test state = true' 382s + for TEST_SUBSET in $modpath/tests/* 382s + echo /usr/lib/python3/dist-packages/pandas/tests/groupby 382s + grep -q -e __pycache__ 382s + PANDAS_CI=1 382s + LC_ALL=C.UTF-8 382s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/groupby 383s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 383s 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" 383s 383s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 385s ============================= test session starts ============================== 385s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 385s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 385s rootdir: /usr/lib/python3/dist-packages/pandas 385s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 385s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 385s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 385s collected 29434 items / 1832 deselected / 1 skipped / 27602 selected 385s 386s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_aggregate.py ...............................................................................................................................................................................................................................................................................................................................................x..x.......................................................................x....... 386s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_cython.py ........................................................................................................................................................................ 386s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_numba.py sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 386s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_other.py ........................................ 386s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_corrwith.py . 387s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_describe.py ......................... 387s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_groupby_shift_diff.py ............................................... 387s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_is_monotonic.py ...... 387s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_nlargest_nsmallest.py ........................................... 387s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_nth.py .................................................................................................................................................................................................................................... 388s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_quantile.py ..................................................................................................x....x.......................................................................................................................................................................................................................... 390s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_rank.py ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 390s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_sample.py .............. 391s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_size.py .......x....x....x....x....x....x....x....x...............ss 391s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_skew.py . 392s ../../../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...................................... 393s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_all_methods.py ......................................xx..............................................................................................ss..........ss..............ss...... 393s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_api.py ......s..s..............................s..s.......................... 393s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_apply.py .................................................................................................................................... 393s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_apply_mutate.py ..... 393s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_bin_groupby.py ...... 402s ../../../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................................ 402s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_counting.py .................................ssss 402s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_cumulative.py ..................................................... 402s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_filters.py ............................ 407s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_groupby.py ......................................s..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s...................s................................................................................................................... 419s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_groupby_dropna.py ..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................xxxxxxxx.................................................. 420s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_groupby_subclass.py .....s................................................................. 420s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_grouping.py ....................................................................................... 420s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_index_as_string.py .................. 420s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_indexing.py ............................................................................................................................................................................ 420s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_libgroupby.py ........................... 420s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_missing.py ......................... 421s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_numeric_only.py ..................xxx......ssssss..............................xxx.................................................................................................................................................................................................................................................................................................................................................................................. 421s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_pipe.py .. 437s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_raises.py ..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 438s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_reductions.py ...............................................................................................................................................................................................................................................................................................................ss........................................................................................................................................................ 438s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_timegrouper.py ..............................s 438s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/transform/test_numba.py sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 446s ../../../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............................................................................................................................................................................................................ 446s 446s =============================== warnings summary =============================== 446s tests/groupby/test_categorical.py::test_basic 446s /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) 446s return reduction(axis=axis, out=out, **passkwargs) 446s 446s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 446s /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-59f3zq83' 446s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 446s 446s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 446s /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-2iqc_6dy' 446s session.config.cache.set(STEPWISE_CACHE_DIR, []) 446s 446s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 446s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 446s ============================= slowest 30 durations ============================= 446s 0.24s call tests/groupby/test_reductions.py::test_ops_general[sem-scipy_sem] 446s 0.24s call tests/groupby/test_raises.py::test_groupby_raises_category_on_category[by2-True-cumsum-False-agg] 446s 0.12s call tests/groupby/test_groupby.py::test_empty_groupby[False-skew-agg-float-keys1-C] 446s 0.11s teardown tests/groupby/transform/test_transform.py::test_idxmin_idxmax_transform_args[False-False-idxmin] 446s 0.05s call tests/groupby/test_categorical.py::test_basic 446s 0.05s call tests/groupby/test_counting.py::test_count 446s 0.04s call tests/groupby/test_counting.py::TestCounting::test_ngroup_cumcount_pair 446s 0.04s call tests/groupby/test_groupby_subclass.py::test_groupby_preserves_subclass[corrwith-obj0] 446s 0.03s call tests/groupby/test_timegrouper.py::TestGroupBy::test_timegrouper_with_reg_groups 446s 0.03s call tests/groupby/test_categorical.py::test_datetime 446s 0.03s call tests/groupby/test_apply.py::test_apply_concat_preserve_names 446s 0.03s call tests/groupby/test_libgroupby.py::TestGroupVarFloat64::test_group_var_large_inputs 446s 0.03s call tests/groupby/methods/test_describe.py::test_frame_describe_multikey 446s 0.02s call tests/groupby/test_groupby.py::test_groupby_multiindex_not_lexsorted 446s 0.02s call tests/groupby/transform/test_transform.py::test_as_index_no_change[corrwith-keys1] 446s 0.02s call tests/groupby/test_apply.py::test_apply_corner_cases 446s 0.02s call tests/groupby/transform/test_transform.py::test_transform_fast 446s 0.02s call tests/groupby/test_categorical.py::test_observed[False] 446s 0.02s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-False-False-False-multi] 446s 0.02s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-False-True-True-multi] 446s 0.02s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-False-False-True-multi] 446s 0.02s call tests/groupby/test_categorical.py::test_describe_categorical_columns 446s 0.01s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-True-False-True-multi] 446s 0.01s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-False-True-False-multi] 446s 0.01s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-True-True-True-multi] 446s 0.01s call tests/groupby/test_groupby.py::test_groupby_as_index_agg 446s 0.01s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-False-False-True-single] 446s 0.01s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-True-True-False-multi] 446s 0.01s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-False-True-True-single] 446s 0.01s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-True-False-False-multi] 446s = 26564 passed, 910 skipped, 1832 deselected, 90 xfailed, 39 xpassed, 3 warnings in 63.74s (0:01:03) = 447s rdjoqkol test state = true 447s + echo 'rdjoqkol test state = true' 447s + for TEST_SUBSET in $modpath/tests/* 447s + echo /usr/lib/python3/dist-packages/pandas/tests/indexes 447s + grep -q -e __pycache__ 447s + PANDAS_CI=1 447s + LC_ALL=C.UTF-8 447s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/indexes 448s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 448s 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" 448s 448s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 453s ============================= test session starts ============================== 453s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 453s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 453s rootdir: /usr/lib/python3/dist-packages/pandas 453s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 453s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 453s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 453s collected 17010 items / 4 deselected / 17006 selected 453s 453s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_constructors.py .......s.. 453s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_formats.py .............. 453s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_indexing.py ............ 453s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_pickle.py . 453s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_reshape.py ..............s.... 453s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_setops.py ............................................................ 453s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_where.py . 453s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_append.py ....... 453s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_astype.py ........... 453s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_category.py ......................................... 453s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_constructors.py ..... 453s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_equals.py ......ss 453s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_fillna.py ... 453s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_formats.py .. 453s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_indexing.py ................................. 453s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_map.py ..................... 453s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_reindex.py ....... 453s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_setops.py .. 453s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_drop_duplicates.py ................................................................................................................ 453s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_equals.py ..................... 453s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_indexing.py ................ 453s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_is_monotonic.py . 453s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_nat.py ...................... 453s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_sort_values.py ................................................................................... 453s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_value_counts.py ............................................ 453s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_asof.py .. 453s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_astype.py ................................. 453s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_delete.py ....................... 453s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_factorize.py .................................................................................... 453s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_fillna.py .. 454s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_insert.py ............................................................................................................................................................................................. 454s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_isocalendar.py .. 454s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_map.py ..... 454s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_normalize.py ......... 454s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_repeat.py .................................................................................................................................................................................................................................................................................................................................................... 454s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_resolution.py .................................................................................................................................................................................... 454s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_round.py ...................................................................................................................................................................................................................... 455s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_shift.py ........................................................................................................................................ 455s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_snap.py ........................ 455s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_to_frame.py .. 455s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_to_julian_date.py ..... 455s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_to_period.py ........................................... 455s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_to_pydatetime.py .. 455s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_to_series.py . 455s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_tz_convert.py .................................... 455s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_tz_localize.py ............................................................................................................................................................ 455s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_unique.py ........................ 455s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_arithmetic.py .....................x 455s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_constructors.py ..................................................................................................................................................................................................................x...x.................................... 457s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_date_range.py .................................................................................................................................................................................................................................................................................................................................................. 457s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_datetime.py .................. 457s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_formats.py ........................................ 457s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_freq_attr.py .......................... 457s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_indexing.py .......................................................................................................................................................................................................................................................................................................................................................................................... 457s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_iter.py ............ 457s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_join.py ...................... 457s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_npfuncs.py . 457s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_ops.py ................ 457s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_partial_slicing.py .................................. 457s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_pickle.py ...... 457s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_reindex.py .. 461s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_scalar_compat.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 461s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_setops.py ................................................................................................................................ 462s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_timezones.py ........................................ 462s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_astype.py ....................................x........................................................................................................................... 462s ../../../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 462s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_equals.py .... 462s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_formats.py ........... 463s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_indexing.py ............................................................................................................................................................................................................................................................................................ 463s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_interval.py .......x....x....x....x.................................................................................................................................................................................................................................. 463s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_interval_range.py ........................................................................................................................................................ 464s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_interval_tree.py .................................................................................................................................................................................................................... 464s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_join.py ... 464s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_pickle.py ... 464s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_setops.py ................................................................................. 464s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_analytics.py ...................................... 464s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_astype.py ... 464s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_compat.py ...... 464s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_constructors.py ..................................................................................s................. 464s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_conversion.py ...... 464s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_copy.py .......... 464s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_drop.py ............. 464s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_duplicates.py .................................................. 464s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_equivalence.py .............. 464s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_formats.py .............. 464s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_get_level_values.py ....... 464s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_get_set.py ................... 465s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_indexing.py ........................................................................................................................................... 465s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_integrity.py ................ 465s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_isin.py .............. 465s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_join.py ....................................................... 465s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_lexsort.py .. 465s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_missing.py ...x.. 465s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_monotonic.py ........... 465s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_names.py ............................... 465s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_partial_indexing.py ..... 465s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_pickle.py . 465s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_reindex.py ............ 465s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_reshape.py ........... 466s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_setops.py ............................................................................................................................................................................................................sss................................................................... 466s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_sorting.py .......................... 466s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_take.py ... 466s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/numeric/test_astype.py ................... 466s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/numeric/test_indexing.py ..............................................................................................................................................ss.......................................... 466s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/numeric/test_join.py ........... 466s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/numeric/test_numeric.py ................................................................................................ 466s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/numeric/test_setops.py .................... 466s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/object/test_astype.py .. 467s ../../../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. 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_asfreq.py ............... 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_astype.py ............. 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_factorize.py .. 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_fillna.py . 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_insert.py ... 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_is_full.py . 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_repeat.py ...... 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_shift.py ...... 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_to_timestamp.py ........ 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_constructors.py .................................................................................................. 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_formats.py ................... 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_freq_attr.py . 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_indexing.py ......................................................................... 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_join.py ........... 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_monotonic.py .. 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_partial_slicing.py .............. 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_period.py .................................................................................................................................... 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_period_range.py ........................... 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_pickle.py .... 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_resolution.py ......... 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_scalar_compat.py ... 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_searchsorted.py ........ 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_setops.py .............. 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_tools.py ............ 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/ranges/test_constructors.py ............................. 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/ranges/test_indexing.py ............... 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/ranges/test_join.py .......... 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/ranges/test_range.py ................................................................................. 468s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/ranges/test_setops.py ................................................................... 468s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_any_index.py ......................................................................................................................s......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 469s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_base.py .........................................................................................................................................................................x.............................................................................ssss....ss..........ss......ss.................................................................................................................................ssss...........................................................................................................................................................................................................................................s.......................................................................................................s..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s 470s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_common.py ...........................................................................................................................................................................................................xxxxxxxxxxxxxxxxxxxxxxxxxxxxx.........................................................................................................................sssssssss...s....ss..........................xs.....................sss................................................sss....................................................................................s................s...............................................................................................................................................................................................................................................................................XX........................................... 470s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_datetimelike.py ........................................ 470s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_engines.py ......................................... 470s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_frozen.py .......... 471s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_index_new.py ............................................xxxxssss................................................................................................................ 471s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_indexing.py ......................................................ss...............................s.................................................................................................................................................................................................................................................................................................s........................ 472s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_numpy_compat.py ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ss..................... 473s ../../../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... 476s ../../../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 476s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_subclass.py . 476s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/methods/test_astype.py ............... 476s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/methods/test_factorize.py .. 476s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/methods/test_fillna.py . 476s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/methods/test_insert.py ............... 476s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/methods/test_repeat.py . 476s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/methods/test_shift.py ...... 476s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_arithmetic.py ... 476s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_constructors.py ..................... 476s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_delete.py ... 476s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_formats.py ..... 476s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_freq_attr.py ........... 476s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_indexing.py .................................... 476s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_join.py ....... 476s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_ops.py .......... 476s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_pickle.py . 476s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_scalar_compat.py ........ 476s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_searchsorted.py ........ 476s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_setops.py ................................ 476s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_timedelta.py ... 476s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_timedelta_range.py ............................ 476s 476s =============================== warnings summary =============================== 476s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 476s /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-4b4xgzwz' 476s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 476s 476s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 476s /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-980o1qa0' 476s session.config.cache.set(STEPWISE_CACHE_DIR, []) 476s 476s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 476s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 476s ============================= slowest 30 durations ============================= 476s 0.18s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_begin[s] 476s 0.13s call tests/indexes/period/test_indexing.py::TestGetItem::test_getitem_seconds 476s 0.12s call tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_out[int8] 476s 0.10s call tests/indexes/ranges/test_setops.py::test_range_difference 476s 0.09s 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] 476s 0.09s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_end[ns] 476s 0.09s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_begin[ns] 476s 0.09s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_end[s] 476s 0.09s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_begin[us] 476s 0.09s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_begin[ms] 476s 0.09s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_end[ms] 476s 0.09s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_end[us] 476s 0.07s call tests/indexes/multi/test_indexing.py::test_pyint_engine 476s 0.04s call tests/indexes/datetimes/methods/test_tz_localize.py::TestTZLocalize::test_dti_tz_localize_roundtrip[tzlocal()] 476s 0.04s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[both-1] 476s 0.04s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[left-1] 476s 0.04s call tests/indexes/multi/test_sorting.py::test_remove_unused_levels_large[datetime64[D]-str] 476s 0.04s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[right-1] 476s 0.04s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[neither-1] 476s 0.03s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonNano::test_date_range_freq_matches_reso 476s 0.03s call tests/indexes/datetimes/methods/test_tz_localize.py::TestTZLocalize::test_dti_tz_localize_roundtrip[zoneinfo.ZoneInfo(key='US/Pacific')] 476s 0.03s call tests/indexes/period/test_partial_slicing.py::TestPeriodIndex::test_range_slice_seconds[period_range] 476s 0.03s call tests/indexes/multi/test_integrity.py::test_consistency 476s 0.03s call tests/indexes/datetimes/test_timezones.py::TestDatetimeIndexTimezones::test_with_tz[tz0] 476s 0.03s call tests/indexes/datetimes/test_timezones.py::TestDatetimeIndexTimezones::test_with_tz[tz1] 476s 0.02s call tests/indexes/datetimes/test_constructors.py::TestDatetimeIndex::test_constructor_datetime64_tzformat[W-SUN] 476s 0.02s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[both-10] 476s 0.02s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[left-10] 476s 0.02s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[right-10] 476s 0.02s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[neither-10] 476s = 16700 passed, 254 skipped, 4 deselected, 46 xfailed, 6 xpassed, 2 warnings in 28.41s = 477s + echo 'rdjoqkol test state = true' 477s + for TEST_SUBSET in $modpath/tests/* 477s + echo /usr/lib/python3/dist-packages/pandas/tests/indexing 477s + grep -q -e __pycache__ 477s + PANDAS_CI=1 477s + LC_ALL=C.UTF-8 477s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/indexing 477s rdjoqkol test state = true 477s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 477s 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" 477s 477s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 478s ============================= test session starts ============================== 478s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 478s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 478s rootdir: /usr/lib/python3/dist-packages/pandas 478s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 478s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 478s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 478s collected 4389 items 478s 478s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/interval/test_interval.py .............................. 478s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/interval/test_interval_new.py ..................... 478s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_chaining_and_caching.py .. 478s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_datetime.py .. 478s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_getitem.py ............................................................................. 478s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_iloc.py ................ 479s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_indexing_slow.py .......... 479s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_loc.py ................................................................................................................................. 479s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_multiindex.py ................ 479s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_partial.py ............. 479s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_setitem.py ........................... 480s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_slice.py ............................. 480s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_sorted.py ......... 480s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_at.py ......................................... 480s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_categorical.py .................s................................................................................................ 480s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_chaining_and_caching.py .............................. 480s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_check_indexer.py ....................s.... 481s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_coercion.py ..........xxxxxxx...............................................................xx............................................xxxx....x............................................................xxxxx..................xx............................................................................................................................................................................................................x 481s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_datetime.py .........ss 481s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_floats.py ............................................................................................................................................... 481s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_iat.py ..... 481s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_iloc.py .................................................................................................................................................................................................................. 481s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_indexers.py ...... 483s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_indexing.py ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 485s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_loc.py .............................................................................................................................x...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s...................................................................................................................................................................................................................................................................................................................................................................s.................................... 485s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_na_indexing.py .............................................................................................................................................................................................................................................................................. 485s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_partial.py .................................... 486s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_scalar.py ...................................... 486s 486s =============================== warnings summary =============================== 486s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 486s /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-iu2wxsxe' 486s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 486s 486s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 486s /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-nh4kfrrm' 486s session.config.cache.set(STEPWISE_CACHE_DIR, []) 486s 486s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 486s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 486s ============================= slowest 30 durations ============================= 486s 0.37s call tests/indexing/test_loc.py::TestLocBaseIndependent::test_loc_non_unique_memory_error[900000-100000] 486s 0.10s call tests/indexing/test_loc.py::TestLocBaseIndependent::test_loc_getitem_range_from_spmatrix[int64-coo_matrix] 486s 0.07s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[a-4] 486s 0.07s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[a-2] 486s 0.07s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[a-3] 486s 0.07s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[a-1] 486s 0.07s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[a-0] 486s 0.07s call tests/indexing/test_chaining_and_caching.py::TestChaining::test_detect_chained_assignment_implicit_take2 486s 0.06s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[b-1] 486s 0.06s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[b-2] 486s 0.06s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[b-3] 486s 0.06s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[b-4] 486s 0.06s call tests/indexing/test_chaining_and_caching.py::TestChaining::test_detect_chained_assignment_str 486s 0.06s call tests/indexing/test_chaining_and_caching.py::TestChaining::test_detect_chained_assignment_setting_entire_column 486s 0.06s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[b-0] 486s 0.06s call tests/indexing/test_chaining_and_caching.py::TestChaining::test_detect_chained_assignment_implicit_take 486s 0.03s call tests/indexing/multiindex/test_setitem.py::TestMultiIndexSetItem::test_groupby_example 486s 0.02s call tests/indexing/test_loc.py::TestLocSeries::test_loc_nonunique_masked_index 486s 0.02s call tests/indexing/multiindex/test_slice.py::TestMultiIndexSlicers::test_per_axis_per_level_setitem 486s 0.02s teardown tests/indexing/test_scalar.py::TestMultiIndexScalar::test_multiindex_at_get_one_level 486s 0.02s call tests/indexing/multiindex/test_slice.py::TestMultiIndexSlicers::test_per_axis_per_level_getitem 486s 0.01s call tests/indexing/multiindex/test_slice.py::TestMultiIndexSlicers::test_per_axis_per_level_doc_examples 486s 0.01s call tests/indexing/multiindex/test_setitem.py::TestMultiIndexSetItem::test_setitem_multiindex3 486s 0.01s call tests/indexing/multiindex/test_slice.py::TestMultiIndexSlicers::test_loc_axis_arguments 486s 0.01s call tests/indexing/test_loc.py::TestLocCallable::test_frame_loc_setitem_callable 486s 0.01s call tests/indexing/test_chaining_and_caching.py::TestChaining::test_detect_chained_assignment_false_positives 486s 0.01s call tests/indexing/multiindex/test_slice.py::TestMultiIndexSlicers::test_multiindex_slicers_non_unique 486s 0.01s call tests/indexing/test_indexing.py::TestMisc::test_rhs_alignment 486s 0.01s call tests/indexing/test_categorical.py::TestCategoricalIndex::test_ix_categorical_index_non_unique[False] 486s 0.01s call tests/indexing/test_loc.py::TestLocBaseIndependent::test_loc_setitem_consistency_slice_column_len 486s =========== 4360 passed, 6 skipped, 23 xfailed, 2 warnings in 8.53s ============ 486s rdjoqkol test state = true 486s + echo 'rdjoqkol test state = true' 486s + for TEST_SUBSET in $modpath/tests/* 486s + echo /usr/lib/python3/dist-packages/pandas/tests/interchange 486s + grep -q -e __pycache__ 486s + PANDAS_CI=1 486s + LC_ALL=C.UTF-8 486s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/interchange 486s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 486s 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" 486s 486s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 486s ============================= test session starts ============================== 486s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 486s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 486s rootdir: /usr/lib/python3/dist-packages/pandas 486s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 486s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 486s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 486s collected 140 items 486s 486s ../../../usr/lib/python3/dist-packages/pandas/tests/interchange/test_impl.py ..sssssssss..............sssss........s..s..ssssssssssssssssssssssssssssssss. 486s ../../../usr/lib/python3/dist-packages/pandas/tests/interchange/test_spec_conformance.py ................ 487s ../../../usr/lib/python3/dist-packages/pandas/tests/interchange/test_utils.py ................sssssssssssssssssssssssssssssss 487s 487s =============================== warnings summary =============================== 487s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 487s /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-om2_rw32' 487s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 487s 487s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 487s /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-hsuwphul' 487s session.config.cache.set(STEPWISE_CACHE_DIR, []) 487s 487s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 487s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 487s ============================= slowest 30 durations ============================= 487s 0.01s call tests/interchange/test_impl.py::test_dataframe[4] 487s 0.01s call tests/interchange/test_impl.py::test_dataframe[3] 487s 0.01s call tests/interchange/test_impl.py::test_dataframe[0] 487s 487s (27 durations < 0.005s hidden. Use -vv to show these durations.) 487s ================== 61 passed, 79 skipped, 2 warnings in 0.31s ================== 487s + echo 'rdjoqkol test state = true' 487s + for TEST_SUBSET in $modpath/tests/* 487s rdjoqkol test state = true 487s + echo /usr/lib/python3/dist-packages/pandas/tests/internals 487s + grep -q -e __pycache__ 487s + PANDAS_CI=1 487s + LC_ALL=C.UTF-8 487s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/internals 487s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 487s 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" 487s 487s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 487s ============================= test session starts ============================== 487s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 487s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 487s rootdir: /usr/lib/python3/dist-packages/pandas 487s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 487s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 487s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 487s collected 257 items 487s 487s ../../../usr/lib/python3/dist-packages/pandas/tests/internals/test_api.py ......... 488s ../../../usr/lib/python3/dist-packages/pandas/tests/internals/test_internals.py .................................................................................................................................................................................................................................................... 488s ../../../usr/lib/python3/dist-packages/pandas/tests/internals/test_managers.py .... 488s 488s =============================== warnings summary =============================== 488s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 488s /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-h8p_s8ae' 488s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 488s 488s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 488s /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-8iwpgdtl' 488s session.config.cache.set(STEPWISE_CACHE_DIR, []) 488s 488s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 488s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 488s ============================= slowest 30 durations ============================= 488s 0.24s call tests/internals/test_managers.py::test_array_manager_depr_env_var[block] 488s 0.23s call tests/internals/test_managers.py::test_array_manager_depr_env_var[array] 488s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_equals_block_order_different_dtypes[c:sparse;d:sparse_na;b:f8] 488s 488s (27 durations < 0.005s hidden. Use -vv to show these durations.) 488s ======================= 257 passed, 2 warnings in 1.08s ======================== 488s rdjoqkol test state = true 488s + echo 'rdjoqkol test state = true' 488s + for TEST_SUBSET in $modpath/tests/* 488s + echo /usr/lib/python3/dist-packages/pandas/tests/io 488s + grep -q -e __pycache__ 488s + PANDAS_CI=1 488s + LC_ALL=C.UTF-8 488s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/io 489s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 489s 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" 489s 489s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 494s ============================= test session starts ============================== 494s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 494s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 494s rootdir: /usr/lib/python3/dist-packages/pandas 494s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 494s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 494s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 494s collected 15019 items / 201 deselected / 18 skipped / 14818 selected 494s 494s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_odf.py ..... 494s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_odswriter.py .......... 495s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_openpyxl.py ...................................................... 504s ../../../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 505s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_style.py ...................................................................................................................................s 512s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_writers.py .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 512s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_xlrd.py ....... 512s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_xlsxwriter.py ..... 513s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_bar.py ..........................................................................................................................s 513s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_exceptions.py ... 513s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_format.py ......................................................................................................... 513s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_highlight.py ................................................................................................ 513s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_html.py ........................................................................................... 513s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_matplotlib.py ........................................................... 513s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_non_unique.py ......... 514s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_style.py ................................................................................................................................................................................................. 514s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_to_latex.py ............................................................................................................................................................ 514s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_to_string.py ..... 514s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_tooltip.py .... 514s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_console.py ........... 514s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_css.py ............................................................................................... 514s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_eng_formatting.py ....... 515s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_format.py .................................................................................................................................................................................. 515s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_ipython_compat.py ss..s 515s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_printing.py ......... 515s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_csv.py ..........s.................................................................................. 516s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_excel.py .......................................................................................................................................................................................................................................................................................................................................................................................................................... 516s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_html.py .....................................................................................................................................................................................................................................................................................................................................................................s................... 516s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_latex.py ............................................................................................ 516s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_markdown.py .......... 517s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_string.py ...............................................s........................................... 517s ../../../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....... 517s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_deprecated_kwargs.py . 517s ../../../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........................... 517s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_json_table_schema_ext_dtype.py ..................... 517s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_normalize.py ..................................................... 520s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_pandas.py ...........................................................................................................xxxx................................xxx........................................................................................................................................................................s........xxxxxxxxxxxxxxxxxx................................................................xx.............s.....x........ssssssssssssssssssssssssssssssss...sssss.s. 520s ../../../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........... 520s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_ujson.py ................................................................................................................................................................................................................... 521s ../../../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 521s ../../../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 521s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_data_list.py ...s...s...s...s 521s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_decimal.py ......ss...s 522s ../../../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 522s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_float.py ...s.......s.....................sss....x.....x...ss 522s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_index.py ......ss......ss...s............ssss...s...s...s...s...s...s...s 522s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_inf.py ......ss......ss...s 523s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_ints.py ...s............ssss...s......ss...s.........sss.........sss......ss......ss...s 523s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_iterator.py ...s...s...s.........sss...s 523s ../../../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 523s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_verbose.py ...s...s 523s ../../../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 525s ../../../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 525s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/dtypes/test_empty.py ...s...s...s...s...s...s...s...s........................ssssssss 525s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_c_parser_only.py .......................................................................... 525s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_comment.py ......ss.........sss...s...s...s..................ssssss......ssxx.s 526s ../../../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 526s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_concatenate_chunks.py ss 526s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_converters.py ...s............ssss...s...s...s......ss...s...s 527s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_dialect.py ...s...s...s......................................................ssssssssssssssssss..................ssssss 527s ../../../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 527s ../../../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 528s ../../../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 528s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_mangle_dupes.py ...s...s...s.........sss.........sss...s...s...s......ss 528s ../../../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 538s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py ................ssss.....ssssssssssssssssss 539s ../../../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 539s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_python_parser_only.py ..................................................................................... 539s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_quoting.py .........sss......ss...s..................ssssss............ssss...............sssss......ss......ss......ss 539s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_read_fwf.py ..........................................................................sss.. 540s ../../../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 540s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_textreader.py ..................................... 540s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_unsupported.py ..........s...s..xs...s 540s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_upcast.py ...........................ssss 540s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/usecols/test_parse_dates.py ......ss...s...s...s............ssss 540s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/usecols/test_strings.py ...s...s......ss......ss 540s ../../../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 540s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_pytables_missing.py . 541s ../../../usr/lib/python3/dist-packages/pandas/tests/io/sas/test_byteswap.py .......... 541s ../../../usr/lib/python3/dist-packages/pandas/tests/io/sas/test_sas.py ... 541s ../../../usr/lib/python3/dist-packages/pandas/tests/io/sas/test_sas7bdat.py ....................... 541s ../../../usr/lib/python3/dist-packages/pandas/tests/io/sas/test_xport.py ....... 541s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_clipboard.py .......QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-ubuntu' 542s ...............................................................................................................................................................................................................................................................................................................................ssssss.. 542s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_common.py .......................................................s....ss.......ss.......ss........ss......s.....s................................... 543s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_compression.py ........................................................................................................................................ 543s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_fsspec.py .........ssssssssss..........s 543s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_gbq.py .. 543s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_gcs.py ssssssssssssssssss. 551s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_html.py .........ssssss...............................................................................................................................s.................... 556s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py ...ss.......ss.......ss....ss 556s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_parquet.py .ssss.ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.ssssssss 560s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_pickle.py ...........s..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 561s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_s3.py sss 561s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_spss.py .......s.. 569s ../../../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................ 574s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_stata.py XXXXXXXXXXXXXXXXXxXXXXXXXXXxXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXxxXXXXXXXxXXXXXXXXXXXxxxxxXXsXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 574s ../../../usr/lib/python3/dist-packages/pandas/tests/io/xml/test_to_xml.py ........................................................................s...............................................................ss 578s ../../../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. 578s ../../../usr/lib/python3/dist-packages/pandas/tests/io/xml/test_xml_dtypes.py .............................................. 578s 578s =============================== warnings summary =============================== 578s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 578s /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-ttfjaf1j' 578s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 578s 578s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 578s /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-ca5s35jy' 578s session.config.cache.set(STEPWISE_CACHE_DIR, []) 578s 578s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 578s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 578s ============================= slowest 30 durations ============================= 578s 1.08s call tests/io/test_html.py::TestReadHtml::test_banklist_url[bs4] 578s 0.86s call tests/io/test_pickle.py::test_pickle_big_dataframe_compression[gzip-4] 578s 0.86s call tests/io/test_pickle.py::test_pickle_big_dataframe_compression[gzip-5] 578s 0.50s teardown tests/io/parser/common/test_file_buffer_url.py::test_url[c_high] 578s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[None-gz_csv_responder-read_csv] 578s 0.50s teardown tests/io/parser/common/test_file_buffer_url.py::test_url[c_low] 578s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[zip-python-explicit] 578s 0.50s teardown tests/io/xml/test_xml.py::test_url 578s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[bz2-python-infer] 578s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[zip-c-infer] 578s 0.50s teardown tests/io/xml/test_xml.py::test_wrong_url[etree] 578s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[xz-python-infer] 578s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[zstd-python-explicit] 578s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[bz2-python-explicit] 578s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[zstd-python-infer] 578s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[storage_options1-pickle_respnder-read_pickle] 578s 0.50s teardown tests/io/test_html.py::TestReadHtml::test_python_docs_table[bs4] 578s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[xz-c-explicit] 578s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[zip-python-infer] 578s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[zip-c-explicit] 578s 0.50s teardown tests/io/excel/test_readers.py::TestReaders::test_read_from_http_url[(None, '.xls')] 578s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[xz-python-explicit] 578s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[storage_options1-gz_csv_responder-read_csv] 578s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[storage_options1-stata_responder-read_stata] 578s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[storage_options2-json_responder-read_json] 578s 0.50s teardown tests/io/xml/test_xml.py::test_wrong_url[lxml] 578s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[storage_options1-csv_responder-read_csv] 578s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[None-gz_json_responder-read_json] 578s 0.50s teardown tests/io/test_html.py::TestReadHtml::test_bad_url_protocol[bs4] 578s 0.50s teardown tests/io/xml/test_xml.py::test_url_path_error[lxml] 578s = 11049 passed, 3035 skipped, 201 deselected, 152 xfailed, 600 xpassed, 2 warnings in 89.25s (0:01:29) = 579s rdjoqkol test state = true 579s + echo 'rdjoqkol test state = true' 579s + for TEST_SUBSET in $modpath/tests/* 579s + echo /usr/lib/python3/dist-packages/pandas/tests/libs 579s + grep -q -e __pycache__ 579s + PANDAS_CI=1 579s + LC_ALL=C.UTF-8 579s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/libs 579s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 579s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 579s 579s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 579s ============================= test session starts ============================== 579s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 579s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 579s rootdir: /usr/lib/python3/dist-packages/pandas 579s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 579s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 579s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 579s collected 2279 items 579s 581s ../../../usr/lib/python3/dist-packages/pandas/tests/libs/test_hashtable.py ..............s.....................................................................s.............s.......................................................s.............s.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s................................................................................................................................................................................................. 581s ../../../usr/lib/python3/dist-packages/pandas/tests/libs/test_join.py ................. 581s ../../../usr/lib/python3/dist-packages/pandas/tests/libs/test_lib.py .................................................................................. 581s ../../../usr/lib/python3/dist-packages/pandas/tests/libs/test_libalgos.py ........ 581s 581s =============================== warnings summary =============================== 581s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 581s /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-6m7814zb' 581s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 581s 581s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 581s /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-e1_glc5m' 581s session.config.cache.set(STEPWISE_CACHE_DIR, []) 581s 581s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 581s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 581s ============================= slowest 30 durations ============================= 581s 0.01s teardown tests/libs/test_libalgos.py::TestInfinity::test_infinity_against_nan 581s 0.01s call tests/libs/test_hashtable.py::test_unique_label_indices 581s 581s (28 durations < 0.005s hidden. Use -vv to show these durations.) 581s ================= 2273 passed, 6 skipped, 2 warnings in 1.86s ================== 581s + echo 'rdjoqkol test state = true' 581s + for TEST_SUBSET in $modpath/tests/* 581s + echo /usr/lib/python3/dist-packages/pandas/tests/plotting 581s + grep -q -e __pycache__ 581s + PANDAS_CI=1 581s + LC_ALL=C.UTF-8 581s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/plotting 581s rdjoqkol test state = true 582s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 582s 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" 582s 582s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 583s ============================= test session starts ============================== 583s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 583s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 583s rootdir: /usr/lib/python3/dist-packages/pandas 583s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 583s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 583s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 583s collected 1423 items / 212 deselected / 1211 selected 583s 593s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame.py ..................................................XX.........................s.s.s.s....................................................................................................x...................................................................................... 596s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame_color.py ......................................................................................... 596s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame_groupby.py ...... 597s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame_legend.py x..................... 600s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame_subplots.py .........x....................XX................................................................... 601s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_hist_box_by.py ............................. 601s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_backend.py .....s. 603s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_boxplot_method.py .................................................... 603s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_common.py ... 604s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_converter.py ............................................ 611s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_datetimelike.py ...............................................................................................................x..........................................x.......................x...............x..... 612s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_groupby.py ................. 614s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_hist_method.py ...........................x..x...................................................... 619s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_misc.py s....................sss...................sss...................sss.................................. 621s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_series.py ...............................XXXX.............................x........................................................x......................... 621s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_style.py ...................................... 621s 621s =============================== warnings summary =============================== 621s tests/plotting/frame/test_frame.py: 11 warnings 621s /usr/lib/python3/dist-packages/matplotlib/transforms.py:2650: RuntimeWarning: divide by zero encountered in scalar divide 621s x_scale = 1.0 / inw 621s 621s tests/plotting/frame/test_frame.py: 11 warnings 621s /usr/lib/python3/dist-packages/matplotlib/transforms.py:2652: RuntimeWarning: invalid value encountered in scalar multiply 621s self._mtx = np.array([[x_scale, 0.0, -inl*x_scale], 621s 621s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 621s /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-zs_2bumu' 621s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 621s 621s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 621s /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-zxfhssvj' 621s session.config.cache.set(STEPWISE_CACHE_DIR, []) 621s 621s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 621s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 621s ============================= slowest 30 durations ============================= 621s 0.41s call tests/plotting/test_converter.py::test_registry_mpl_resets 621s 0.39s call tests/plotting/test_misc.py::TestDataFramePlots::test_scatter_matrix_axis_smaller[True] 621s 0.37s call tests/plotting/test_datetimelike.py::TestTSPlot::test_finder_daily 621s 0.34s call tests/plotting/test_converter.py::TestRegistration::test_dont_register_by_default 621s 0.32s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_errorbar_timeseries[bar] 621s 0.31s call tests/plotting/test_misc.py::TestSeriesPlots::test_bootstrap_plot 621s 0.30s call tests/plotting/test_misc.py::TestDataFramePlots::test_scatter_matrix_axis[True] 621s 0.27s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_errorbar_timeseries[barh] 621s 0.27s call tests/plotting/frame/test_frame_subplots.py::TestDataFramePlotsSubplots::test_subplots_ts_share_axes 621s 0.25s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_kde_df 621s 0.24s call tests/plotting/test_misc.py::TestDataFramePlots::test_scatter_matrix_axis[False] 621s 0.24s call tests/plotting/test_misc.py::TestDataFramePlots::test_scatter_matrix_axis_smaller[False] 621s 0.22s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_sharex_and_ax 621s 0.21s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_errorbar_timeseries[line] 621s 0.20s call tests/plotting/test_boxplot_method.py::TestDataFrameGroupByPlots::test_boxplot_legacy3[True-UserWarning-3-layout0] 621s 0.20s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_sharey_and_ax 621s 0.19s call tests/plotting/test_boxplot_method.py::TestDataFrameGroupByPlots::test_boxplot_legacy3[False-None-1-layout1] 621s 0.19s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_df_gridspec_patterns_vert_horiz 621s 0.17s call tests/plotting/test_misc.py::test_savefig[index2-data0-hexbin] 621s 0.17s call tests/plotting/test_misc.py::test_savefig[index0-data0-hexbin] 621s 0.17s call tests/plotting/test_misc.py::test_savefig[index1-data0-hexbin] 621s 0.17s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_hist_df 621s 0.17s call tests/plotting/test_boxplot_method.py::TestDataFramePlots::test_stacked_boxplot_set_axis 621s 0.16s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_hist_df_coord[data0] 621s 0.16s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_hist_df_coord[data1] 621s 0.16s call tests/plotting/frame/test_frame_subplots.py::TestDataFramePlotsSubplots::test_subplots_constrained_layout 621s 0.16s call tests/plotting/test_hist_method.py::TestDataFrameGroupByPlots::test_histtype_argument[barstacked-True] 621s 0.16s call tests/plotting/test_datetimelike.py::TestTSPlot::test_line_plot_period_mlt_series[4D] 621s 0.14s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_bar_bottom_left_subplots 621s 0.13s call tests/plotting/frame/test_frame_subplots.py::TestDataFramePlotsSubplots::test_subplots_dup_columns_secondary_y 621s = 1177 passed, 15 skipped, 212 deselected, 11 xfailed, 8 xpassed, 24 warnings in 39.45s = 621s rdjoqkol test state = true 621s + echo 'rdjoqkol test state = true' 621s + for TEST_SUBSET in $modpath/tests/* 621s + echo /usr/lib/python3/dist-packages/pandas/tests/reductions 621s + grep -q -e __pycache__ 621s + PANDAS_CI=1 621s + LC_ALL=C.UTF-8 621s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/reductions 622s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 622s 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" 622s 622s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 622s ============================= test session starts ============================== 622s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 622s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 622s rootdir: /usr/lib/python3/dist-packages/pandas 622s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 622s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 622s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 622s collected 550 items 622s 623s ../../../usr/lib/python3/dist-packages/pandas/tests/reductions/test_reductions.py .....................................................................................................................................................................................................................................................................................................................................s....................................................................................................................................... 623s ../../../usr/lib/python3/dist-packages/pandas/tests/reductions/test_stat_reductions.py ......................................................................................... 623s 623s =============================== warnings summary =============================== 623s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 623s /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-xs8r6ff8' 623s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 623s 623s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 623s /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-y021800l' 623s session.config.cache.set(STEPWISE_CACHE_DIR, []) 623s 623s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 623s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 623s ============================= slowest 30 durations ============================= 623s 0.23s call tests/reductions/test_stat_reductions.py::TestSeriesStatReductions::test_skew 623s 0.02s call tests/reductions/test_reductions.py::TestIndexReductions::test_minmax_tz['Asia/Tokyo'] 623s 0.02s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_float[float32-True] 623s 0.02s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_float[float32-False] 623s 0.01s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_float[float64-True] 623s 0.01s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_float[float64-False] 623s 0.01s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_int[int32-True] 623s 0.01s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_int[int32-False] 623s 0.01s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_int[int64-True] 623s 0.01s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_int[int64-False] 623s 623s (20 durations < 0.005s hidden. Use -vv to show these durations.) 623s ================== 549 passed, 1 skipped, 2 warnings in 1.18s ================== 623s rdjoqkol test state = true 623s + echo 'rdjoqkol test state = true' 623s + for TEST_SUBSET in $modpath/tests/* 623s + echo /usr/lib/python3/dist-packages/pandas/tests/resample 623s + grep -q -e __pycache__ 623s + PANDAS_CI=1 623s + LC_ALL=C.UTF-8 623s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/resample 624s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 624s 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" 624s 624s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 624s ============================= test session starts ============================== 624s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 624s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 624s rootdir: /usr/lib/python3/dist-packages/pandas 624s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 624s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 624s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 624s collected 4179 items 624s 626s ../../../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............................................................................................................................................................................................................................................................................................................................................................................................................................................................. 638s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_datetime_index.py ................................................................................ssss............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x...x...x...x..........................................................................................................................................................................................................................................................................................................................................................................ss 640s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_period_index.py .................................................................................................................................................................................................................................................................................................................................................................................................................................x.................................................................................. 641s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_resample_api.py ..................................................................................................................................................................................................... 641s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_resampler_grouper.py s................................................... 641s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_time_grouper.py .........................x...................... 641s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_timedelta.py .......................s 641s 641s =============================== warnings summary =============================== 641s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 641s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-p5vv04xq' 641s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 641s 641s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 641s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-zbz0rvry' 641s session.config.cache.set(STEPWISE_CACHE_DIR, []) 641s 641s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 641s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 641s ============================= slowest 30 durations ============================= 641s 0.11s call tests/resample/test_datetime_index.py::test_resample_dtype_coercion[s] 641s 0.09s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-30-s-0.5-Min-1] 641s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-30-s-0.5-Min-1] 641s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-60-s-1-Min-1] 641s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-30-s-0.5-Min-3] 641s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-21600-s-0.25-D-3] 641s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-30-s-0.5-Min-2] 641s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-30-s-0.5-Min-1] 641s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-60-s-1-Min-2] 641s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-30-s-0.5-Min-2] 641s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-86400-s-1-D-1] 641s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-21600-s-0.25-D-1] 641s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-60-s-1-Min-1] 641s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-60-s-1-Min-3] 641s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-86400-s-1-D-3] 641s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-86400-s-1-D-2] 641s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-60-s-1-Min-2] 641s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-43200-s-0.5-D-3] 641s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-3600-s-1-h-1] 641s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-43200-s-0.5-D-1] 641s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-60-s-1-Min-2] 641s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-30-s-0.5-Min-3] 641s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-43200-s-0.5-D-1] 641s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-43200-s-0.5-D-1] 641s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-86400-s-1-D-1] 641s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-43200-s-0.5-D-2] 641s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-30-s-0.5-Min-3] 641s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-60-s-1-Min-1] 641s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-3600-s-1-h-3] 641s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-21600-s-0.25-D-1] 641s =========== 4117 passed, 8 skipped, 54 xfailed, 2 warnings in 17.61s =========== 641s + echo 'rdjoqkol test state = true' 641s + for TEST_SUBSET in $modpath/tests/* 641s rdjoqkol test state = true 641s + echo /usr/lib/python3/dist-packages/pandas/tests/reshape 641s + grep -q -e __pycache__ 641s + PANDAS_CI=1 641s + LC_ALL=C.UTF-8 641s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/reshape 642s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 642s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 642s 642s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 643s ============================= test session starts ============================== 643s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 643s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 643s rootdir: /usr/lib/python3/dist-packages/pandas 643s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 643s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 643s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 643s collected 2610 items / 1 deselected / 2609 selected 643s 643s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_append.py .................................................................................. 643s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_append_common.py ...........................sssssssss....................................................... 643s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_categorical.py ............. 643s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_concat.py .............................................................................................. 643s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_dataframe.py ..................... 644s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_datetimes.py ..................................................................................................x......... 644s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_empty.py .....................s.....s.....s.....s.....s.......... 644s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_index.py ............................................................. 644s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_invalid.py ....... 644s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_series.py ............. 644s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_sort.py .......... 644s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_join.py .......s..........................s....................................... 646s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge.py ..............................................................................................................................................................................................................................................................................................................................................................................................................................ssssssss..............................................................................................................................................................................................................................ss..........................................................................................................................................................................................................................................................................ssss........ 647s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge_asof.py .s...................................................................................................s.....................s....s.s.s.s.............sss.. 647s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge_cross.py ................. 647s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge_index_as_string.py ................................................................................ 647s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge_ordered.py ..................... 647s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_multi.py .....s.s.................................. 648s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_crosstab.py ..................................... 648s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_cut.py ..................................................................................................................................... 648s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_from_dummies.py ......................................... 648s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_get_dummies.py ...................................................................................................................................................ss 649s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_melt.py ..........................................................s 650s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_pivot.py ...........................................................................xx................................................................................................. 650s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_pivot_multilevel.py .......... 650s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_qcut.py ................................................................................ 650s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_union_categoricals.py .......................................... 650s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_util.py ................. 650s 650s =============================== warnings summary =============================== 650s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 650s /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-51vb3o9q' 650s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 650s 650s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 650s /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-rcvexitq' 650s session.config.cache.set(STEPWISE_CACHE_DIR, []) 650s 650s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 650s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 650s ============================= slowest 30 durations ============================= 650s 0.05s call tests/reshape/test_pivot.py::TestPivotTable::test_pivot_multi_functions 650s 0.04s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_normalize 650s 0.04s call tests/reshape/merge/test_join.py::TestJoin::test_full_outer_join 650s 0.03s call tests/reshape/concat/test_concat.py::TestConcatenate::test_concat_order 650s 0.03s call tests/reshape/merge/test_merge.py::TestMerge::test_merge_non_unique_indexes 650s 0.03s call tests/reshape/merge/test_multi.py::TestMergeMulti::test_compress_group_combinations 650s 0.03s call tests/reshape/test_pivot.py::TestPivotTable::test_margins 650s 0.03s call tests/reshape/test_crosstab.py::TestCrosstab::test_margin_normalize 650s 0.03s call tests/reshape/test_crosstab.py::TestCrosstab::test_margin_dropna6 650s 0.03s call tests/reshape/merge/test_join.py::TestJoin::test_right_outer_join 650s 0.02s call tests/reshape/test_qcut.py::test_qcut_binning_issues 650s 0.02s call tests/reshape/test_pivot.py::TestPivotTable::test_daily 650s 0.02s call tests/reshape/test_pivot.py::TestPivotTable::test_pivot_timegrouper 650s 0.02s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_normalize_arrays 650s 0.02s call tests/reshape/test_crosstab.py::test_categoricals[category-category] 650s 0.02s call tests/reshape/test_crosstab.py::test_categoricals[int64-category] 650s 0.02s call tests/reshape/test_crosstab.py::test_categoricals[category-int64] 650s 0.02s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_margins_set_margin_name 650s 0.01s call tests/reshape/merge/test_join.py::TestJoin::test_join_many_non_unique_index 650s 0.01s call tests/reshape/test_crosstab.py::test_categoricals[int64-int64] 650s 0.01s teardown tests/reshape/test_util.py::TestCartesianProduct::test_exceed_product_space 650s 0.01s call tests/reshape/test_pivot.py::TestPivotTable::test_pivot_timegrouper_double 650s 0.01s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_ndarray[list] 650s 0.01s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_ndarray[tuple] 650s 0.01s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_ndarray[array] 650s 0.01s call tests/reshape/merge/test_merge.py::TestMerge::test_validation 650s 0.01s call tests/reshape/test_pivot.py::TestPivotTable::test_pivot_table_margins_name_with_aggfunc_list 650s 0.01s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_duplicate_names 650s 0.01s call tests/reshape/merge/test_join.py::TestJoin::test_left_outer_join 650s 0.01s call tests/reshape/merge/test_multi.py::TestMergeMulti::test_left_join_multi_index[True-False] 650s ==== 2561 passed, 45 skipped, 1 deselected, 3 xfailed, 2 warnings in 8.62s ===== 651s rdjoqkol test state = true 651s + echo 'rdjoqkol test state = true' 651s + for TEST_SUBSET in $modpath/tests/* 651s + echo /usr/lib/python3/dist-packages/pandas/tests/scalar 651s + grep -q -e __pycache__ 651s + PANDAS_CI=1 651s + LC_ALL=C.UTF-8 651s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/scalar 651s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 651s 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" 651s 651s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 653s ============================= test session starts ============================== 653s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 653s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 653s rootdir: /usr/lib/python3/dist-packages/pandas 653s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 653s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 653s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 653s collected 4353 items 653s 653s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_arithmetic.py ............................................ 653s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_constructors.py ......... 653s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_contains.py ................ 653s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_formats.py . 653s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_interval.py ............................................ 653s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_overlaps.py ................................................................................................................................................................. 653s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/period/test_arithmetic.py .................................................................................... 653s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/period/test_asfreq.py ....................... 654s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/period/test_period.py ............................................................................................................................................................................................................................................................................................................... 654s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/test_na_scalar.py .....................................................................................ss.....ss.....ss................................................................................................................................................................................ 654s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/test_nat.py ........................................................................................................................s............s............................................................................................................................................................................................................................ 654s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/methods/test_as_unit.py .... 654s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/methods/test_round.py ................... 654s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/test_arithmetic.py ................................................................................................................................ 655s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/test_constructors.py ................................................................................................................................................................................................................................................................................................................... 655s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/test_formats.py .............. 657s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/test_timedelta.py .................................................................x............ 657s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_as_unit.py .... 657s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_normalize.py ................................................................................................................................................................. 657s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_replace.py ............................................................................................................................ 657s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_round.py ....................................................................................................................................................................................... 657s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_timestamp_method.py . 657s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_to_julian_date.py ..... 657s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_to_pydatetime.py ....... 657s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_tz_convert.py ............................................................................... 658s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_tz_localize.py ................................................................................................................................................................................................. 658s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_arithmetic.py ............................................................................................................. 658s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_comparisons.py .............................. 658s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_constructors.py ..................................................................xxx.............................................................. 658s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_formats.py ........................................................................... 660s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_timestamp.py .............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x....................................................................................................................................................................................................................................................................................................................................... 660s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_timezones.py .................... 660s 660s =============================== warnings summary =============================== 660s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 660s /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-lvm7w34_' 660s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 660s 660s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 660s /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-zjnm8axs' 660s session.config.cache.set(STEPWISE_CACHE_DIR, []) 660s 660s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 660s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 660s ============================= slowest 30 durations ============================= 660s 1.92s call tests/scalar/timedelta/test_timedelta.py::TestTimedeltas::test_hash_equality_invariance 660s 0.09s call tests/scalar/timestamp/methods/test_round.py::TestTimestampRound::test_round_sanity[round] 660s 0.09s call tests/scalar/timestamp/methods/test_round.py::TestTimestampRound::test_round_sanity[floor] 660s 0.08s call tests/scalar/timedelta/methods/test_round.py::TestTimedeltaRound::test_round_sanity[round] 660s 0.08s call tests/scalar/timestamp/methods/test_round.py::TestTimestampRound::test_round_sanity[ceil] 660s 0.08s call tests/scalar/timedelta/methods/test_round.py::TestTimedeltaRound::test_round_sanity[floor] 660s 0.07s call tests/scalar/timedelta/methods/test_round.py::TestTimedeltaRound::test_round_sanity[ceil] 660s 0.07s call tests/scalar/timestamp/test_timestamp.py::TestTimestampProperties::test_dow_parametric 660s 0.03s teardown tests/scalar/timestamp/test_timezones.py::TestTimestampTZOperations::test_timestamp_timetz_equivalent_with_datetime_tz[zoneinfo.ZoneInfo(key='UTC')] 660s 660s (21 durations < 0.005s hidden. Use -vv to show these durations.) 660s ============ 4340 passed, 8 skipped, 5 xfailed, 2 warnings in 8.91s ============ 660s rdjoqkol test state = true 660s + echo 'rdjoqkol test state = true' 660s + for TEST_SUBSET in $modpath/tests/* 660s + echo /usr/lib/python3/dist-packages/pandas/tests/series 660s + grep -q -e __pycache__ 660s + PANDAS_CI=1 660s + LC_ALL=C.UTF-8 660s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/series 661s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 661s 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" 661s 661s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 664s ============================= test session starts ============================== 664s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 664s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 664s rootdir: /usr/lib/python3/dist-packages/pandas 664s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 664s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 664s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 664s collected 13032 items / 2 skipped 664s 664s ../../../usr/lib/python3/dist-packages/pandas/tests/series/accessors/test_cat_accessor.py ................... 668s ../../../usr/lib/python3/dist-packages/pandas/tests/series/accessors/test_dt_accessor.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 668s ../../../usr/lib/python3/dist-packages/pandas/tests/series/accessors/test_sparse_accessor.py . 668s ../../../usr/lib/python3/dist-packages/pandas/tests/series/accessors/test_str_accessor.py .. 668s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_datetime.py ................. 668s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_delitem.py .... 668s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_get.py ............ 668s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_getitem.py .............................................................................................. 669s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_indexing.py .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 669s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_mask.py .... 669s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_set_value.py ... 671s ../../../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................................................................................................................................................................................................... 671s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_take.py .... 672s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_where.py ......................................................................................................................................................................................................... 672s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_xs.py ...... 672s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_add_prefix_suffix.py ... 672s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_align.py ............................................................................................................... 672s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_argsort.py ......... 672s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_asof.py ....... 672s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_astype.py ........................................................s....s..........................................................................x........sssssssss.................s 672s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_autocorr.py . 672s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_between.py ....... 672s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_case_when.py ........... 672s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_clip.py ....s.....s.....s.....s.....s.....s.....s.....s.....s.....s............ 672s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_combine.py . 672s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_combine_first.py .............................. 673s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_compare.py ............ 673s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_convert_dtypes.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s......ss 673s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_copy.py .......... 673s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_count.py ... 674s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_cov_corr.py ................ 674s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_describe.py ...................................................... 674s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_diff.py ....... 674s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_drop.py ............................. 674s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_drop_duplicates.py ..................................................................ssssss.............................................................................................................................................................................................................................................................................................................ss 674s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_dropna.py ........... 674s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_dtypes.py . 674s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_duplicated.py .................. 674s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_equals.py ..................................................... 674s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_explode.py ...............ssss 675s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_fillna.py ....................x.x.x................................................................................................................................. 675s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_get_numeric_data.py . 675s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_head_tail.py . 675s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_infer_objects.py ....... 675s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_info.py ........x..... 675s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_interpolate.py x.........................................................................................................................................................................................................x.x............. 675s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_is_monotonic.py .. 675s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_is_unique.py ........ 675s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_isin.py ......................................... 675s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_isna.py .. 675s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_item.py . 676s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_map.py ......ss...................................xxx....................................................... 676s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_matmul.py . 676s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_nlargest.py ................................................................. 676s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_nunique.py .. 676s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_pct_change.py .............. 676s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_pop.py . 676s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_quantile.py ........................................ 677s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_rank.py .......................................................................................................ssssssssssssssssssssssssssssss........................................................ssssssssssssssss.....ss.....ss.....ss.....ss.....ss.....................................................ssssssssssssssssss.............................................ssssssssssssssssss.............................................ssssssssssssssssss.............................................ssssssssssssssssss.............................................ssssssssssssssssss. 677s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_reindex.py ................................... 677s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_reindex_like.py .. 677s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_rename.py ................ 677s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_rename_axis.py ..... 677s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_repeat.py ... 677s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_replace.py ...........................s.......................................................................... 677s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_reset_index.py ........s...... 677s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_round.py ......................................................................................... 677s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_searchsorted.py ........ 677s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_set_name.py .. 677s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_size.py ....... 677s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_sort_index.py .............................................. 677s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_sort_values.py .............. 677s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_to_csv.py ................................... 677s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_to_dict.py ...... 677s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_to_frame.py ... 677s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_to_numpy.py ...s. 677s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_tolist.py ..........sss 677s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_truncate.py .... 677s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_tz_localize.py ................................................................ 677s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_unique.py ....... 677s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_unstack.py ....... 677s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_update.py ....................s..... 677s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_value_counts.py ................... 677s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_values.py ... 678s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_view.py .................................................. 678s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_api.py ................................s.......................................................................................................................................................... 682s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_arithmetic.py ..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x...............................x............. 683s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_constructors.py ......................................................................................................................................................................................................................................x.........x............................................................................................s.................................xx.................................................sssssss.s...................... 683s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_cumulative.py ....................................... 683s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_formats.py .................................................. 683s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_iteration.py ....... 683s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_logical_ops.py ..........................xs 683s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_missing.py ...x.. 683s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_npfuncs.py ....s 683s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_reductions.py ..............s............... 683s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_subclass.py ......... 684s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_ufunc.py .....................................................................xxxx........................................................................................................................................ 684s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_unary.py .......................... 684s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_validate.py ............................ 684s 684s =============================== warnings summary =============================== 684s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 684s /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-a4hll464' 684s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 684s 684s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 684s /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-0oew4r0v' 684s session.config.cache.set(STEPWISE_CACHE_DIR, []) 684s 684s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 684s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 684s ============================= slowest 30 durations ============================= 684s 0.47s call tests/series/methods/test_rank.py::test_pct_max_many_rows 684s 0.28s call tests/series/test_formats.py::TestSeriesRepr::test_latex_repr 684s 0.23s call tests/series/methods/test_cov_corr.py::TestSeriesCorr::test_corr[float64] 684s 0.10s call tests/series/test_arithmetic.py::TestNamePreservation::test_series_ops_name_retention[numexpr-names3-pow-True-array0] 684s 0.07s call tests/series/methods/test_convert_dtypes.py::TestSeriesConvertDtypes::test_convert_dtypes[test_cases16-params9] 684s 0.07s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[chr_US.UTF-8] 684s 0.06s call tests/series/methods/test_isin.py::TestSeriesIsIn::test_isin 684s 0.06s teardown tests/series/test_validate.py::test_validate_bool_args[5.0-drop_duplicates] 684s 0.02s call tests/series/test_api.py::TestSeriesMisc::test_inspect_getmembers 684s 0.01s call tests/series/accessors/test_cat_accessor.py::TestCatAccessor::test_dt_accessor_api_for_categorical[idx1] 684s 0.01s call tests/series/accessors/test_cat_accessor.py::TestCatAccessor::test_dt_accessor_api_for_categorical[idx0] 684s 0.01s call tests/series/indexing/test_datetime.py::test_getitem_str_month_with_datetimeindex 684s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[shn_MM.UTF-8] 684s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[br_FR.UTF-8] 684s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[gbm_IN.UTF-8] 684s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[my_MM.UTF-8] 684s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ar_SA.UTF-8] 684s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ar_SA.ISO8859-6] 684s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ar_IQ.UTF-8] 684s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[en_HK.UTF-8] 684s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ckb_IQ.UTF-8] 684s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[en_US.UTF-8_0] 684s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[da_DK.UTF-8] 684s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[en_PH.ISO8859-1] 684s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ar_OM.UTF-8] 684s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[en_HK.ISO8859-1] 684s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[am_ET.UTF-8] 684s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[aa_ER.UTF-8] 684s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ar_YE.ISO8859-6] 684s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[byn_ER.UTF-8] 684s ========= 12405 passed, 606 skipped, 23 xfailed, 2 warnings in 23.59s ========== 685s rdjoqkol test state = true 685s + echo 'rdjoqkol test state = true' 685s + for TEST_SUBSET in $modpath/tests/* 685s + echo /usr/lib/python3/dist-packages/pandas/tests/strings 685s + grep -q -e __pycache__ 685s + PANDAS_CI=1 685s + LC_ALL=C.UTF-8 685s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/strings 685s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 685s 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" 685s 685s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 686s ============================= test session starts ============================== 686s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 686s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 686s rootdir: /usr/lib/python3/dist-packages/pandas 686s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 686s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 686s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 686s collected 3604 items 686s 688s ../../../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 688s ../../../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 688s ../../../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...................................... 689s ../../../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 689s ../../../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 689s ../../../usr/lib/python3/dist-packages/pandas/tests/strings/test_get_dummies.py ..ss...ss. 689s ../../../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 689s ../../../usr/lib/python3/dist-packages/pandas/tests/strings/test_string_array.py ...............................................................................sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss....ssss....ssss.s 690s ../../../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....... 690s 690s =============================== warnings summary =============================== 690s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 690s /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-_x5582o9' 690s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 690s 690s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 690s /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-poznxl12' 690s session.config.cache.set(STEPWISE_CACHE_DIR, []) 690s 690s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 690s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 690s ============================= slowest 30 durations ============================= 690s 0.04s call tests/strings/test_strings.py::test_ismethods[string[python]-isalpha-expected1] 690s 0.01s call tests/strings/test_strings.py::test_empty_str_methods[string[python]] 690s 0.01s teardown tests/strings/test_strings.py::test_series_str_decode 690s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data5-names5] 690s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data6-names6] 690s 0.01s call tests/strings/test_strings.py::test_empty_str_methods[object] 690s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data7-names7] 690s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data3-names3] 690s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data2-names2] 690s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data7-names7] 690s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data5-names5] 690s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data6-names6] 690s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data2-names2] 690s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data3-names3] 690s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data0-names0] 690s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data1-names1] 690s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data4-names4] 690s 690s (13 durations < 0.005s hidden. Use -vv to show these durations.) 690s ========== 2704 passed, 887 skipped, 13 xfailed, 2 warnings in 4.54s =========== 690s rdjoqkol test state = true 690s + echo 'rdjoqkol test state = true' 690s + for TEST_SUBSET in $modpath/tests/* 690s + echo /usr/lib/python3/dist-packages/pandas/tests/test_aggregation.py 690s + grep -q -e __pycache__ 690s + PANDAS_CI=1 690s + LC_ALL=C.UTF-8 690s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_aggregation.py 690s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 690s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 690s 690s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 690s ============================= test session starts ============================== 690s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 690s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 690s rootdir: /usr/lib/python3/dist-packages/pandas 690s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 690s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 690s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 690s collected 8 items 690s 690s ../../../usr/lib/python3/dist-packages/pandas/tests/test_aggregation.py ........ 690s 690s =============================== warnings summary =============================== 690s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 690s /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-w176notr' 690s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 690s 690s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 690s /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-7yf8npg3' 690s session.config.cache.set(STEPWISE_CACHE_DIR, []) 690s 690s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 690s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 690s ============================= slowest 30 durations ============================= 690s 690s (24 durations < 0.005s hidden. Use -vv to show these durations.) 690s ======================== 8 passed, 2 warnings in 0.08s ========================= 691s + echo 'rdjoqkol test state = true' 691s + for TEST_SUBSET in $modpath/tests/* 691s rdjoqkol test state = true 691s + echo /usr/lib/python3/dist-packages/pandas/tests/test_algos.py 691s + grep -q -e __pycache__ 691s + PANDAS_CI=1 691s + LC_ALL=C.UTF-8 691s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_algos.py 691s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 691s 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" 691s 691s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 691s ============================= test session starts ============================== 691s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 691s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 691s rootdir: /usr/lib/python3/dist-packages/pandas 691s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 691s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 691s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 691s collected 471 items 691s 694s ../../../usr/lib/python3/dist-packages/pandas/tests/test_algos.py ....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 694s 694s =============================== warnings summary =============================== 694s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 694s /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-xxqxz9p3' 694s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 694s 694s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 694s /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-i67m5fou' 694s session.config.cache.set(STEPWISE_CACHE_DIR, []) 694s 694s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 694s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 694s ============================= slowest 30 durations ============================= 694s 2.24s call tests/test_algos.py::TestRank::test_pct_max_many_rows 694s 0.24s call tests/test_algos.py::TestRank::test_scipy_compat[arr0] 694s 0.01s call tests/test_algos.py::TestIsin::test_large 694s 0.01s call tests/test_algos.py::TestDuplicated::test_datetime_likes 694s 0.01s call tests/test_algos.py::TestUnique::test_object_refcount_bug 694s 0.01s call tests/test_algos.py::TestIsin::test_same_nan_is_in_large_series 694s 694s (24 durations < 0.005s hidden. Use -vv to show these durations.) 694s ======================= 471 passed, 2 warnings in 3.15s ======================== 694s + echo 'rdjoqkol test state = true' 694s + for TEST_SUBSET in $modpath/tests/* 694s rdjoqkol test state = true 694s + echo /usr/lib/python3/dist-packages/pandas/tests/test_common.py 694s + grep -q -e __pycache__ 694s + PANDAS_CI=1 694s + LC_ALL=C.UTF-8 694s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_common.py 695s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 695s 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" 695s 695s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 695s ============================= test session starts ============================== 695s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 695s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 695s rootdir: /usr/lib/python3/dist-packages/pandas 695s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 695s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 695s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 695s collected 128 items 695s 696s ../../../usr/lib/python3/dist-packages/pandas/tests/test_common.py ...............x.x.............................................................................................................. 696s 696s =============================== warnings summary =============================== 696s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 696s /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-osgo4dnb' 696s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 696s 696s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 696s /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-u494fgu0' 696s session.config.cache.set(STEPWISE_CACHE_DIR, []) 696s 696s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 696s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 696s ============================= slowest 30 durations ============================= 696s 0.29s call tests/test_common.py::test_bz2_missing_import 696s 0.23s call tests/test_common.py::test_str_size 696s 696s (28 durations < 0.005s hidden. Use -vv to show these durations.) 696s ================== 126 passed, 2 xfailed, 2 warnings in 0.74s ================== 696s + echo 'rdjoqkol test state = true' 696s + for TEST_SUBSET in $modpath/tests/* 696s + echo /usr/lib/python3/dist-packages/pandas/tests/test_downstream.py 696s rdjoqkol test state = true 696s + grep -q -e __pycache__ 696s + PANDAS_CI=1 696s + LC_ALL=C.UTF-8 696s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_downstream.py 696s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 696s 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" 696s 696s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 696s ============================= test session starts ============================== 696s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 696s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 696s rootdir: /usr/lib/python3/dist-packages/pandas 696s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 696s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 696s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 696s collected 26 items 696s 699s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py ....s..sssss.sx.........s. 699s 699s =============================== warnings summary =============================== 699s tests/test_downstream.py::test_dask 699s /usr/lib/python3/dist-packages/dask/dataframe/__init__.py:49: FutureWarning: 699s Dask dataframe query planning is disabled because dask-expr is not installed. 699s 699s You can install it with `pip install dask[dataframe]` or `conda install dask`. 699s This will raise in a future version. 699s 699s warnings.warn(msg, FutureWarning) 699s 699s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 699s /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-zlljt0xq' 699s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 699s 699s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 699s /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-23sr2m_u' 699s session.config.cache.set(STEPWISE_CACHE_DIR, []) 699s 699s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 699s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 699s ============================= slowest 30 durations ============================= 699s 1.34s call tests/test_downstream.py::test_oo_optimizable 699s 1.32s call tests/test_downstream.py::test_oo_optimized_datetime_index_unpickle 699s 0.07s call tests/test_downstream.py::test_dask 699s 0.01s call tests/test_downstream.py::test_yaml_dump 699s 0.01s call tests/test_downstream.py::test_construct_dask_float_array_int_dtype_match_ndarray 699s 699s (25 durations < 0.005s hidden. Use -vv to show these durations.) 699s ============= 17 passed, 8 skipped, 1 xfailed, 3 warnings in 3.14s ============= 699s rdjoqkol test state = true 699s + echo 'rdjoqkol test state = true' 699s + for TEST_SUBSET in $modpath/tests/* 699s + echo /usr/lib/python3/dist-packages/pandas/tests/test_errors.py 699s + grep -q -e __pycache__ 699s + PANDAS_CI=1 699s + LC_ALL=C.UTF-8 699s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_errors.py 700s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 700s 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" 700s 700s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 700s ============================= test session starts ============================== 700s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 700s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 700s rootdir: /usr/lib/python3/dist-packages/pandas 700s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 700s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 700s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 700s collected 36 items 700s 700s ../../../usr/lib/python3/dist-packages/pandas/tests/test_errors.py .................................... 700s 700s =============================== warnings summary =============================== 700s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 700s /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-5902p0f1' 700s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 700s 700s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 700s /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-z7_1_4ug' 700s session.config.cache.set(STEPWISE_CACHE_DIR, []) 700s 700s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 700s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 700s ============================= slowest 30 durations ============================= 700s 700s (30 durations < 0.005s hidden. Use -vv to show these durations.) 700s ======================== 36 passed, 2 warnings in 0.09s ======================== 700s + echo 'rdjoqkol test state = true' 700s + for TEST_SUBSET in $modpath/tests/* 700s rdjoqkol test state = true 700s + echo /usr/lib/python3/dist-packages/pandas/tests/test_expressions.py 700s + grep -q -e __pycache__ 700s + PANDAS_CI=1 700s + LC_ALL=C.UTF-8 700s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_expressions.py 701s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 701s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 701s 701s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 701s ============================= test session starts ============================== 701s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 701s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 701s rootdir: /usr/lib/python3/dist-packages/pandas 701s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 701s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 701s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 701s collected 243 items 701s 701s ../../../usr/lib/python3/dist-packages/pandas/tests/test_expressions.py ................................................................................................................................................................................................................................................... 701s 701s =============================== warnings summary =============================== 701s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 701s /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-vtd7f5yb' 701s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 701s 701s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 701s /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-o7lv8lpm' 701s session.config.cache.set(STEPWISE_CACHE_DIR, []) 701s 701s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 701s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 701s ============================= slowest 30 durations ============================= 701s 0.02s call tests/test_expressions.py::TestExpressions::test_invalid 701s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[ge-False-_integer_integers] 701s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-False-_integer_integers] 701s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[lt-False-_mixed2] 701s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-False-_mixed] 701s 701s (25 durations < 0.005s hidden. Use -vv to show these durations.) 701s ======================= 243 passed, 2 warnings in 0.82s ======================== 701s + echo 'rdjoqkol test state = true' 701s rdjoqkol test state = true 701s + for TEST_SUBSET in $modpath/tests/* 701s + echo /usr/lib/python3/dist-packages/pandas/tests/test_flags.py 701s + grep -q -e __pycache__ 701s + PANDAS_CI=1 701s + LC_ALL=C.UTF-8 701s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_flags.py 702s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 702s 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" 702s 702s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 702s ============================= test session starts ============================== 702s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 702s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 702s rootdir: /usr/lib/python3/dist-packages/pandas 702s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 702s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 702s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 702s collected 5 items 702s 702s ../../../usr/lib/python3/dist-packages/pandas/tests/test_flags.py ..... 702s 702s =============================== warnings summary =============================== 702s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 702s /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-3hf1pt03' 702s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 702s 702s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 702s /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-p1lpg5os' 702s session.config.cache.set(STEPWISE_CACHE_DIR, []) 702s 702s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 702s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 702s ============================= slowest 30 durations ============================= 702s 702s (15 durations < 0.005s hidden. Use -vv to show these durations.) 702s ======================== 5 passed, 2 warnings in 0.08s ========================= 702s rdjoqkol test state = true 702s + echo 'rdjoqkol test state = true' 702s + for TEST_SUBSET in $modpath/tests/* 702s + echo /usr/lib/python3/dist-packages/pandas/tests/test_multilevel.py 702s + grep -q -e __pycache__ 702s + PANDAS_CI=1 702s + LC_ALL=C.UTF-8 702s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_multilevel.py 703s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 703s 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" 703s 703s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 703s ============================= test session starts ============================== 703s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 703s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 703s rootdir: /usr/lib/python3/dist-packages/pandas 703s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 703s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 703s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 703s collected 19 items 703s 703s ../../../usr/lib/python3/dist-packages/pandas/tests/test_multilevel.py ................... 703s 703s =============================== warnings summary =============================== 703s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 703s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-os2g2ru7' 703s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 703s 703s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 703s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-gcuqs7ub' 703s session.config.cache.set(STEPWISE_CACHE_DIR, []) 703s 703s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 703s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 703s ============================= slowest 30 durations ============================= 703s 0.01s call tests/test_multilevel.py::TestMultiLevel::test_reindex_level 703s 703s (29 durations < 0.005s hidden. Use -vv to show these durations.) 703s ======================== 19 passed, 2 warnings in 0.14s ======================== 703s + echo 'rdjoqkol test state = true' 703s + for TEST_SUBSET in $modpath/tests/* 703s + echo /usr/lib/python3/dist-packages/pandas/tests/test_nanops.py 703s + grep -q -e __pycache__ 703s + PANDAS_CI=1 703s + LC_ALL=C.UTF-8 703s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_nanops.py 703s rdjoqkol test state = true 703s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 703s 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" 703s 703s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 703s ============================= test session starts ============================== 703s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 703s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 703s rootdir: /usr/lib/python3/dist-packages/pandas 703s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 703s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 703s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 703s collected 245 items 703s 704s ../../../usr/lib/python3/dist-packages/pandas/tests/test_nanops.py ..................................................................................................................................................................................................................................................... 704s 704s =============================== warnings summary =============================== 704s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 704s /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-224v180r' 704s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 704s 704s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 704s /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-zdoy65sd' 704s session.config.cache.set(STEPWISE_CACHE_DIR, []) 704s 704s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 704s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 704s ============================= slowest 30 durations ============================= 704s 0.24s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[True-0] 704s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nankurt[True] 704s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanskew[True] 704s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[True-1] 704s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[True-2] 704s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nankurt[False] 704s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanskew[False] 704s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nancorr_spearman 704s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanmedian[True] 704s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[False-1] 704s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[False-2] 704s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[False-0] 704s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanmedian[False] 704s 704s (17 durations < 0.005s hidden. Use -vv to show these durations.) 704s ======================= 245 passed, 2 warnings in 0.79s ======================== 704s rdjoqkol test state = true 704s + echo 'rdjoqkol test state = true' 704s + for TEST_SUBSET in $modpath/tests/* 704s + echo /usr/lib/python3/dist-packages/pandas/tests/test_optional_dependency.py 704s + grep -q -e __pycache__ 704s + PANDAS_CI=1 704s + LC_ALL=C.UTF-8 704s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_optional_dependency.py 705s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 705s 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" 705s 705s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 705s ============================= test session starts ============================== 705s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 705s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 705s rootdir: /usr/lib/python3/dist-packages/pandas 705s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 705s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 705s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 705s collected 5 items 705s 705s ../../../usr/lib/python3/dist-packages/pandas/tests/test_optional_dependency.py ..... 705s 705s =============================== warnings summary =============================== 705s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 705s /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-15u654od' 705s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 705s 705s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 705s /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-gghgqsf7' 705s session.config.cache.set(STEPWISE_CACHE_DIR, []) 705s 705s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 705s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 705s ============================= slowest 30 durations ============================= 705s 705s (15 durations < 0.005s hidden. Use -vv to show these durations.) 705s ======================== 5 passed, 2 warnings in 0.08s ========================= 705s rdjoqkol test state = true 705s + echo 'rdjoqkol test state = true' 705s + for TEST_SUBSET in $modpath/tests/* 705s + echo /usr/lib/python3/dist-packages/pandas/tests/test_register_accessor.py 705s + grep -q -e __pycache__ 705s + PANDAS_CI=1 705s + LC_ALL=C.UTF-8 705s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_register_accessor.py 705s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 705s 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" 705s 705s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 705s ============================= test session starts ============================== 705s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 705s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 705s rootdir: /usr/lib/python3/dist-packages/pandas 705s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 705s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 705s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 705s collected 7 items 705s 705s ../../../usr/lib/python3/dist-packages/pandas/tests/test_register_accessor.py ....... 705s 705s =============================== warnings summary =============================== 705s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 705s /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-7i0eels5' 705s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 705s 705s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 705s /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-ow2damrb' 705s session.config.cache.set(STEPWISE_CACHE_DIR, []) 705s 705s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 705s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 705s ============================= slowest 30 durations ============================= 705s 705s (21 durations < 0.005s hidden. Use -vv to show these durations.) 705s ======================== 7 passed, 2 warnings in 0.08s ========================= 706s rdjoqkol test state = true 706s + echo 'rdjoqkol test state = true' 706s + for TEST_SUBSET in $modpath/tests/* 706s + echo /usr/lib/python3/dist-packages/pandas/tests/test_sorting.py 706s + grep -q -e __pycache__ 706s + PANDAS_CI=1 706s + LC_ALL=C.UTF-8 706s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_sorting.py 706s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 706s 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" 706s 706s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 706s ============================= test session starts ============================== 706s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 706s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 706s rootdir: /usr/lib/python3/dist-packages/pandas 706s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 706s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 706s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 706s collected 54 items / 15 deselected / 39 selected 706s 707s ../../../usr/lib/python3/dist-packages/pandas/tests/test_sorting.py ....................................... 707s 707s =============================== warnings summary =============================== 707s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 707s /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-ru8aw11l' 707s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 707s 707s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 707s /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-sdxetxo6' 707s session.config.cache.set(STEPWISE_CACHE_DIR, []) 707s 707s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 707s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 707s ============================= slowest 30 durations ============================= 707s 0.42s call tests/test_sorting.py::TestSorting::test_int64_overflow_groupby_large_range 707s 0.23s call tests/test_sorting.py::TestSorting::test_int64_overflow_groupby_large_df_shuffled[median] 707s 0.23s call tests/test_sorting.py::TestSorting::test_int64_overflow_groupby_large_df_shuffled[mean] 707s 0.01s call tests/test_sorting.py::TestMerge::test_int64_overflow_outer_merge 707s 707s (26 durations < 0.005s hidden. Use -vv to show these durations.) 707s ================ 39 passed, 15 deselected, 2 warnings in 1.02s ================= 707s + echo 'rdjoqkol test state = true' 707s + for TEST_SUBSET in $modpath/tests/* 707s + echo /usr/lib/python3/dist-packages/pandas/tests/test_take.py 707s + grep -q -e __pycache__ 707s rdjoqkol test state = true 707s + PANDAS_CI=1 707s + LC_ALL=C.UTF-8 707s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_take.py 708s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 708s 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" 708s 708s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 708s ============================= test session starts ============================== 708s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 708s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 708s rootdir: /usr/lib/python3/dist-packages/pandas 708s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 708s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 708s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 708s collected 81 items 708s 708s ../../../usr/lib/python3/dist-packages/pandas/tests/test_take.py ................................................................................. 708s 708s =============================== warnings summary =============================== 708s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 708s /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-562liq01' 708s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 708s 708s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 708s /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-1f0g6vts' 708s session.config.cache.set(STEPWISE_CACHE_DIR, []) 708s 708s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 708s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 708s ============================= slowest 30 durations ============================= 708s 708s (30 durations < 0.005s hidden. Use -vv to show these durations.) 708s ======================== 81 passed, 2 warnings in 0.15s ======================== 708s + echo 'rdjoqkol test state = true' 708s rdjoqkol test state = true 708s + for TEST_SUBSET in $modpath/tests/* 708s + echo /usr/lib/python3/dist-packages/pandas/tests/tools 708s + grep -q -e __pycache__ 708s + PANDAS_CI=1 708s + LC_ALL=C.UTF-8 708s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/tools 708s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 708s 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" 708s 708s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 709s ============================= test session starts ============================== 709s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 709s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 709s rootdir: /usr/lib/python3/dist-packages/pandas 709s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 709s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 709s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 709s collected 1510 items 709s 711s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_datetime.py ..................................................................................................................................................................................................................................ssssssss....................................................................ss................................................................................................................................................................................................................................................................................xx..........................................................................................................................................................................................................................................................................................................................................................................ssssssssss............................ 711s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_numeric.py ...s.s....................................................................................................................................................................................................................................................xx.......................................................................................................................ssssss.s.s.................................sss...sss.s....ssss.s.s 711s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_time.py ........... 711s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_timedelta.py ........................................................................ssssssssssss 711s 711s =============================== warnings summary =============================== 711s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 711s /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-l0c37y_v' 711s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 711s 711s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 711s /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-cjcajkj8' 711s session.config.cache.set(STEPWISE_CACHE_DIR, []) 711s 711s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 711s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 711s ============================= slowest 30 durations ============================= 711s 0.05s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[array-%Y%m%d %H:%M:%S-True] 711s 0.05s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[array-None-True] 711s 0.05s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[array-None-None] 711s 0.05s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[array-%Y%m%d %H:%M:%S-None] 711s 0.05s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[list-%Y%m%d %H:%M:%S-True] 711s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[list-%Y%m%d %H:%M:%S-None] 711s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[deque-None-True] 711s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[deque-None-None] 711s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[deque-%Y%m%d %H:%M:%S-True] 711s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[deque-%Y%m%d %H:%M:%S-None] 711s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[list-None-True] 711s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[list-None-None] 711s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[tuple-None-True] 711s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[tuple-None-None] 711s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[tuple-%Y%m%d %H:%M:%S-True] 711s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[tuple-%Y%m%d %H:%M:%S-None] 711s 0.03s 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] 711s 0.02s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[Index-None-True] 711s 0.02s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[Index-None-None] 711s 0.02s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache_series[None-True] 711s 0.02s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache_series[None-None] 711s 0.02s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[Index-%Y%m%d %H:%M:%S-True] 711s 0.02s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[Index-%Y%m%d %H:%M:%S-None] 711s 0.02s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache_series[%Y%m%d %H:%M:%S-None] 711s 0.02s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache_series[%Y%m%d %H:%M:%S-True] 711s 0.02s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_fixed_offset 711s 0.01s call tests/tools/test_to_datetime.py::TestToDatetimeMisc::test_to_datetime_timezone_name 711s 0.01s teardown tests/tools/test_to_timedelta.py::test_from_timedelta_arrow_dtype[ms] 711s 711s (2 durations < 0.005s hidden. Use -vv to show these durations.) 711s =========== 1451 passed, 55 skipped, 4 xfailed, 2 warnings in 2.88s ============ 711s + echo 'rdjoqkol test state = true' 711s + for TEST_SUBSET in $modpath/tests/* 711s + echo /usr/lib/python3/dist-packages/pandas/tests/tseries 711s + grep -q -e __pycache__ 711s rdjoqkol test state = true 711s + PANDAS_CI=1 711s + LC_ALL=C.UTF-8 711s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/tseries 712s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 712s 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" 712s 712s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 713s ============================= test session starts ============================== 713s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 713s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 713s rootdir: /usr/lib/python3/dist-packages/pandas 713s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 713s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 713s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 713s collected 5480 items 713s 713s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/frequencies/test_freq_code.py ................... 713s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/frequencies/test_frequencies.py .......... 714s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/frequencies/test_inference.py ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 714s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/holiday/test_calendar.py ........ 714s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/holiday/test_federal.py ... 714s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/holiday/test_holiday.py ................................................. 714s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/holiday/test_observance.py ................................. 714s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_day.py ....................... 714s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_hour.py .............................................................................................. 714s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_month.py ..................... 714s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_quarter.py .............................................. 714s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_year.py ................... 715s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_common.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 715s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_custom_business_day.py ....... 715s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_custom_business_hour.py ............................ 715s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_custom_business_month.py .................................................... 715s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_dst.py .......................... 715s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_easter.py .......... 715s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_fiscal.py ............................................................................................................................................. 716s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_index.py ........................ 716s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_month.py ............................................................ 719s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_offsets.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x..................................................................................................................................................................................................................................................x................................................................................................................................................................................................................................................ 719s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_offsets_properties.py .. 719s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_quarter.py ........................................................................................ 721s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_ticks.py ............................................................................................................ 721s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_week.py .............................................. 721s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_year.py ................................. 721s 721s =============================== warnings summary =============================== 721s tests/tseries/offsets/test_offsets_properties.py::test_on_offset_implementations 721s /usr/lib/python3/dist-packages/dateutil/zoneinfo/__init__.py:26: UserWarning: I/O error(2): No such file or directory 721s warnings.warn("I/O error({0}): {1}".format(e.errno, e.strerror)) 721s 721s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 721s /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-ditaeq39' 721s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 721s 721s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 721s /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-_odzj1we' 721s session.config.cache.set(STEPWISE_CACHE_DIR, []) 721s 721s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 721s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 721s ============================= slowest 30 durations ============================= 721s 0.26s call tests/tseries/offsets/test_offsets_properties.py::test_on_offset_implementations 721s 0.16s call tests/tseries/offsets/test_offsets_properties.py::test_shift_across_dst 721s 0.14s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Nano] 721s 0.14s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Hour] 721s 0.14s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Micro] 721s 0.14s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Milli] 721s 0.14s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Minute] 721s 0.14s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Second] 721s 0.12s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Nano] 721s 0.09s call tests/tseries/offsets/test_custom_business_day.py::TestCustomBusinessDay::test_calendar 721s 0.09s call tests/tseries/offsets/test_custom_business_hour.py::TestCustomBusinessHour::test_us_federal_holiday_with_datetime 721s 0.06s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Minute] 721s 0.06s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Hour] 721s 0.06s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Micro] 721s 0.06s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Milli] 721s 0.06s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Second] 721s 0.04s call tests/tseries/offsets/test_common.py::test_apply_out_of_range[pytz.FixedOffset(-300)-MonthBegin] 721s 0.04s call tests/tseries/offsets/test_index.py::test_apply_index[BusinessMonthBegin--2] 721s 0.04s call tests/tseries/offsets/test_index.py::test_apply_index[BYearEnd--2] 721s 0.04s call tests/tseries/offsets/test_business_month.py::test_apply_index[BusinessMonthBegin--2] 721s 0.04s call tests/tseries/offsets/test_index.py::test_apply_index[BusinessMonthEnd-1] 721s 0.04s call tests/tseries/offsets/test_index.py::test_apply_index[BQuarterBegin--2] 721s 0.04s call tests/tseries/offsets/test_index.py::test_apply_index[BYearBegin--2] 721s 0.04s call tests/tseries/offsets/test_index.py::test_apply_index[BQuarterEnd--2] 721s 0.03s call tests/tseries/offsets/test_business_month.py::test_apply_index[BusinessMonthEnd-1] 721s 0.03s call tests/tseries/offsets/test_index.py::test_apply_index[BusinessMonthEnd--2] 721s 0.03s call tests/tseries/offsets/test_index.py::test_apply_index[YearEnd--2] 721s 0.03s call tests/tseries/offsets/test_business_month.py::test_apply_index[BusinessMonthEnd--2] 721s 0.03s call tests/tseries/offsets/test_index.py::test_apply_index[QuarterEnd--2] 721s 0.03s call tests/tseries/offsets/test_index.py::test_apply_index[QuarterBegin--2] 721s ================= 5478 passed, 2 xfailed, 3 warnings in 8.78s ================== 721s + echo 'rdjoqkol test state = true' 721s + for TEST_SUBSET in $modpath/tests/* 721s + echo /usr/lib/python3/dist-packages/pandas/tests/tslibs 721s + grep -q -e __pycache__ 721s rdjoqkol test state = true 721s + PANDAS_CI=1 721s + LC_ALL=C.UTF-8 721s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/tslibs 721s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 721s 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" 721s 721s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 722s ============================= test session starts ============================== 722s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 722s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 722s rootdir: /usr/lib/python3/dist-packages/pandas 722s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 722s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 722s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 722s collected 1140 items 722s 722s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_api.py . 722s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_array_to_datetime.py ............................................ 722s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_ccalendar.py ................. 724s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_conversion.py ...................................................................... 724s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_fields.py .... 724s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_libfrequencies.py ............ 724s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_liboffsets.py .......................................................................... 724s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_np_datetime.py ........ 724s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_npy_units.py .. 724s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_parse_iso8601.py ................................................... 728s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_parsing.py .............................................................................................................................................x...x................................. 728s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_period.py ....................................... 728s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_resolution.py ................... 728s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_strptime.py ....... 728s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_timedeltas.py ......................... 729s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_timezones.py ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 729s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_to_offset.py ................................................................................................... 729s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_tzconversion.py . 729s 729s =============================== warnings summary =============================== 729s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 729s /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-kf22t0dw' 729s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 729s 729s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 729s /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-7x5i04zc' 729s session.config.cache.set(STEPWISE_CACHE_DIR, []) 729s 729s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 729s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 729s ============================= slowest 30 durations ============================= 729s 0.20s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['dateutil/Asia/Singapore'] 729s 0.18s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%m %Y-True-.] 729s 0.18s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[tzlocal()] 729s 0.15s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%m %Y-False-.] 729s 0.14s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[datetime.timezone(datetime.timedelta(seconds=3600))] 729s 0.14s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['+01:15'] 729s 0.14s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['-02:15'] 729s 0.14s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['UTC+01:15'] 729s 0.14s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['UTC-02:15'] 729s 0.14s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[datetime.timezone(datetime.timedelta(days=-1, seconds=82800), 'foo')] 729s 0.12s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[pytz.FixedOffset(-300)] 729s 0.12s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[pytz.FixedOffset(300)] 729s 0.10s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-False-/] 729s 0.10s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['Asia/Tokyo'] 729s 0.08s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%m %d %Y-False--] 729s 0.07s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-True- ] 729s 0.07s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-True- ] 729s 0.07s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-False- ] 729s 0.07s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-True-.] 729s 0.07s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-False--] 729s 0.07s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-False- ] 729s 0.07s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-True-/] 729s 0.07s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-False-.] 729s 0.07s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y%m%d-True-.] 729s 0.07s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y%m%d-True- ] 729s 0.07s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-True--] 729s 0.07s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-False-/] 729s 0.07s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-True-/] 729s 0.07s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-True-.] 729s 0.07s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y%m%d-False--] 729s ================= 1138 passed, 2 xfailed, 2 warnings in 7.35s ================== 729s + echo 'rdjoqkol test state = true' 729s rdjoqkol test state = true 729s + for TEST_SUBSET in $modpath/tests/* 729s + echo /usr/lib/python3/dist-packages/pandas/tests/util 729s + grep -q -e __pycache__ 729s + PANDAS_CI=1 729s + LC_ALL=C.UTF-8 729s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/util 729s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 729s 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" 729s 729s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 730s ============================= test session starts ============================== 730s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 730s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 730s rootdir: /usr/lib/python3/dist-packages/pandas 730s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 730s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 730s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 730s collected 916 items 730s 730s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_almost_equal.py .................................................................................................................................................................... 730s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_attr_equal.py .......................................... 730s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_categorical_equal.py .......... 730s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_extension_array_equal.py ..................... 730s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_frame_equal.py ............................................................................................................... 730s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_index_equal.py ................................................................ 730s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_interval_array_equal.py ....... 730s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_numpy_array_equal.py ......................... 730s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_produces_warning.py ............................................................................................................................ 730s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_series_equal.py .............................................................................................. 730s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_deprecate.py ... 730s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_deprecate_kwarg.py .............. 730s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_deprecate_nonkeyword_arguments.py ................... 730s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_doc.py .... 730s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_hashing.py ..................................................................................................................................................... 730s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_numba.py . 730s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_rewrite_warning.py .......... 730s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_shares_memory.py .s 731s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_show_versions.py .... 731s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_util.py ...sx.. 731s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_validate_args.py ...... 731s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_validate_args_and_kwargs.py ...... 731s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_validate_inclusive.py ........... 731s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_validate_kwargs.py .................. 731s 731s =============================== warnings summary =============================== 731s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 731s /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-3pk025va' 731s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 731s 731s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 731s /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-9j57ob4e' 731s session.config.cache.set(STEPWISE_CACHE_DIR, []) 731s 731s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 731s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 731s ============================= slowest 30 durations ============================= 731s 0.43s call tests/util/test_show_versions.py::test_show_versions 731s 0.01s call tests/util/test_hashing.py::test_same_len_hash_collisions[0-7] 731s 0.01s call tests/util/test_hashing.py::test_same_len_hash_collisions[1-7] 731s 0.01s call tests/util/test_hashing.py::test_same_len_hash_collisions[0-6] 731s 0.01s call tests/util/test_hashing.py::test_same_len_hash_collisions[1-6] 731s 731s (25 durations < 0.005s hidden. Use -vv to show these durations.) 731s ============ 913 passed, 2 skipped, 1 xfailed, 2 warnings in 1.56s ============= 731s + echo 'rdjoqkol test state = true' 731s + for TEST_SUBSET in $modpath/tests/* 731s + echo /usr/lib/python3/dist-packages/pandas/tests/window 731s + grep -q -e __pycache__ 731s rdjoqkol test state = true 731s + PANDAS_CI=1 731s + LC_ALL=C.UTF-8 731s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.VZGv7J/build.9qq/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/window 732s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 732s 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" 732s 732s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 733s ============================= test session starts ============================== 733s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 733s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 733s rootdir: /usr/lib/python3/dist-packages/pandas 733s configfile: ../../../../../tmp/autopkgtest.VZGv7J/build.9qq/src/pyproject.toml 733s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 733s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 733s collected 10242 items / 536 deselected / 1 skipped / 9706 selected 733s 734s ../../../usr/lib/python3/dist-packages/pandas/tests/window/moments/test_moments_consistency_ewm.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 735s ../../../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................................................................................................................................................................................................................................................................................ 736s ../../../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................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 737s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_api.py ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 737s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_apply.py ...s....sssss..........s..s....................................................... 738s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_base_indexer.py .................................................................................................................................................................................................................................... 738s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_cython_aggregations.py ........................................................................ 741s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_dtypes.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 741s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_ewm.py .......................................................................................................................................................................................................................................ssssssssssss........ssssssssssssssss................ 742s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_expanding.py ..........x................................................................................................................................................................................................ss....s...................s..s......s............................................................................................. 742s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_groupby.py ................................................................................................................... 742s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_numba.py ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 744s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_pairwise.py ........................................................................................................................................................................................................................................................................................................................ 745s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling.py .........................................................................................................................................................................................................................................................................................................................................................................................xxxx........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 746s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_functions.py .................................................................................................................................................................................................................................................................................................................................................................................................................................. 747s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_quantile.py .......................................................................................................................................................................................... 747s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_skew_kurt.py .................................................................... 747s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_timeseries_window.py ..................................................................................s 747s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_win_type.py ............................................................................................................................................................................................................................................................................................... 747s 747s =============================== warnings summary =============================== 747s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 747s /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-jxgff44g' 747s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 747s 747s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 747s /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-4v6h4cer' 747s session.config.cache.set(STEPWISE_CACHE_DIR, []) 747s 747s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 747s -- generated xml file: /tmp/autopkgtest.VZGv7J/autopkgtest_tmp/test-data.xml --- 747s ============================= slowest 30 durations ============================= 747s 0.24s call tests/window/test_rolling_functions.py::test_rolling_functions_window_non_shrinkage[14] 747s 0.09s call tests/window/test_apply.py::test_time_rule_frame[False] 747s 0.07s teardown tests/window/test_numba.py::TestEWM::test_cython_vs_numba[False-True-True-True-True-sum-groupby] 747s 0.06s call tests/window/test_apply.py::test_frame[False] 747s 0.05s teardown tests/window/test_win_type.py::test_rolling_center_axis_1 747s 0.03s call tests/window/test_expanding.py::test_expanding_corr_pairwise 747s 0.03s call tests/window/test_expanding.py::test_expanding_cov_pairwise 747s 0.02s call tests/window/test_apply.py::test_center_reindex_frame[False] 747s 0.02s call tests/window/test_apply.py::test_min_periods[False-None-0] 747s 0.02s call tests/window/test_apply.py::test_min_periods[False-1-0] 747s 0.02s call tests/window/test_apply.py::test_center_reindex_series[False] 747s 0.02s call tests/window/test_pairwise.py::test_rolling_pairwise_cov_corr[corr] 747s 0.02s call tests/window/test_pairwise.py::test_rolling_pairwise_cov_corr[cov] 747s 0.02s call tests/window/test_ewm.py::test_ewm_pairwise_cov_corr[corr] 747s 0.02s call tests/window/test_ewm.py::test_ewm_pairwise_cov_corr[cov] 747s 0.02s call tests/window/test_pairwise.py::test_flex_binary_frame[corr] 747s 0.01s call tests/window/test_apply.py::test_nans[False] 747s 0.01s call tests/window/test_pairwise.py::test_flex_binary_frame[cov] 747s 0.01s call tests/window/test_expanding.py::test_expanding_cov_pairwise_diff_length 747s 0.01s call tests/window/test_pairwise.py::TestPairwise::test_cov_mulittindex 747s 0.01s call tests/window/test_expanding.py::test_expanding_corr_pairwise_diff_length 747s 0.01s call tests/window/test_apply.py::test_min_periods[False-2-0] 747s 0.01s call tests/window/test_api.py::test_agg[None] 747s 0.01s call tests/window/test_rolling.py::test_multi_index_names 747s 0.01s call tests/window/test_rolling_functions.py::test_rolling_median_memory_error 747s 0.01s call tests/window/test_api.py::test_agg[2] 747s 0.01s call tests/window/test_api.py::test_agg[5] 747s 0.01s call tests/window/test_api.py::test_agg[10] 747s 0.01s call tests/window/test_api.py::test_agg[1] 747s 0.01s call tests/window/test_groupby.py::TestExpanding::test_expanding_corr_cov[corr] 747s == 9010 passed, 650 skipped, 536 deselected, 47 xfailed, 2 warnings in 15.85s == 748s + echo 'rdjoqkol test state = true' 748s + true 748s rdjoqkol test state = true 748s autopkgtest [17:36:08]: test unittests3: -----------------------] 749s unittests3 PASS 749s autopkgtest [17:36:09]: test unittests3: - - - - - - - - - - results - - - - - - - - - - 749s autopkgtest [17:36:09]: test ignoredtests: preparing testbed 749s Reading package lists... 749s Building dependency tree... 749s Reading state information... 749s Starting pkgProblemResolver with broken count: 0 749s Starting 2 pkgProblemResolver with broken count: 0 749s Done 750s The following NEW packages will be installed: 750s libpq5 python3-psycopg2 python3-pymysql 750s 0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded. 750s Need to get 321 kB of archives. 750s After this operation, 1133 kB of additional disk space will be used. 750s Get:1 http://ftpmaster.internal/ubuntu questing/main s390x libpq5 s390x 17.4-1 [147 kB] 750s Get:2 http://ftpmaster.internal/ubuntu questing/main s390x python3-psycopg2 s390x 2.9.10-1build1 [135 kB] 750s Get:3 http://ftpmaster.internal/ubuntu questing/main s390x python3-pymysql all 1.1.1-2ubuntu1 [39.5 kB] 750s Fetched 321 kB in 1s (549 kB/s) 750s Selecting previously unselected package libpq5:s390x. 750s (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 ... 105161 files and directories currently installed.) 750s Preparing to unpack .../libpq5_17.4-1_s390x.deb ... 750s Unpacking libpq5:s390x (17.4-1) ... 750s Selecting previously unselected package python3-psycopg2. 750s Preparing to unpack .../python3-psycopg2_2.9.10-1build1_s390x.deb ... 750s Unpacking python3-psycopg2 (2.9.10-1build1) ... 750s Selecting previously unselected package python3-pymysql. 750s Preparing to unpack .../python3-pymysql_1.1.1-2ubuntu1_all.deb ... 750s Unpacking python3-pymysql (1.1.1-2ubuntu1) ... 750s Setting up libpq5:s390x (17.4-1) ... 750s Setting up python3-psycopg2 (2.9.10-1build1) ... 751s Setting up python3-pymysql (1.1.1-2ubuntu1) ... 751s Processing triggers for libc-bin (2.41-6ubuntu1) ... 752s autopkgtest [17:36:12]: test ignoredtests: [----------------------- 752s === python3.13 === 752s 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 752s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 752s 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" 752s 752s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 753s ============================= test session starts ============================== 753s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 753s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 753s rootdir: /usr/lib/python3/dist-packages/pandas/tests 753s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 753s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 753s collected 10446 items / 536 deselected / 2 skipped / 9910 selected 753s 755s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_ufunc.py ....xx.........xxxxxxxx.xx....s. 756s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_timegrouper.py ..............................s 756s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/transform/test_numba.py sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 757s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_numba.py sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 757s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_numba.py . 771s ../../../usr/lib/python3/dist-packages/pandas/tests/window/moments/test_moments_consistency_ewm.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 776s ../../../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................................................................................................................................................................................................................................................................................ 785s ../../../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................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 795s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_api.py ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 796s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_apply.py ...s....sssss..........s..s....................................................... 800s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_base_indexer.py .................................................................................................................................................................................................................................... 801s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_cython_aggregations.py ........................................................................ 833s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_dtypes.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 836s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_ewm.py .......................................................................................................................................................................................................................................ssssssssssss........ssssssssssssssss................ 841s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_expanding.py ..........x................................................................................................................................................................................................ss....s...................s..s......s............................................................................................. 843s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_groupby.py ................................................................................................................... 847s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_numba.py ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 853s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_pairwise.py ........................................................................................................................................................................................................................................................................................................................ 866s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling.py .........................................................................................................................................................................................................................................................................................................................................................................................xxxx........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 873s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_functions.py .................................................................................................................................................................................................................................................................................................................................................................................................................................. 876s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_quantile.py .......................................................................................................................................................................................... 880s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_skew_kurt.py .................................................................... 881s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_timeseries_window.py ..................................................................................s 957s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_win_type.py ............................................................................................................................................................................................................................................................................................... 957s 957s =============================== warnings summary =============================== 957s ../../../usr/lib/python3/dist-packages/pandas/compat/_optional.py:130 957s ../../../usr/lib/python3/dist-packages/pandas/compat/_optional.py:130 957s ../../../usr/lib/python3/dist-packages/pandas/compat/_optional.py:130 957s ../../../usr/lib/python3/dist-packages/pandas/compat/_optional.py:130 957s ../../../usr/lib/python3/dist-packages/pandas/compat/_optional.py:130 957s /usr/lib/python3/dist-packages/pandas/compat/_optional.py:130: UserWarning: Non-x86 system detected, Numba may give wrong results or crash 957s warnings.warn(warn_numba_platform) 957s 957s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_numba.py:11 957s /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 957s pytestmark = pytest.mark.single_cpu 957s 957s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_timegrouper.py:944 957s /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 957s @pytest.mark.single_cpu 957s 957s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/transform/test_numba.py:14 957s /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 957s pytestmark = pytest.mark.single_cpu 957s 957s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_numba.py:22 957s /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 957s pytestmark = pytest.mark.single_cpu 957s 957s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_numba.py:230 957s /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 957s @pytest.mark.single_cpu 957s 957s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_numba.py:21 957s /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 957s pytestmark = pytest.mark.single_cpu 957s 957s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_numba.py:326 957s /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 957s @pytest.mark.slow 957s 957s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_online.py:11 957s /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 957s pytestmark = pytest.mark.single_cpu 957s 957s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_skew_kurt.py:155 957s /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 957s @pytest.mark.slow 957s 957s frame/test_ufunc.py: 32 warnings 957s groupby/test_timegrouper.py: 31 warnings 957s groupby/transform/test_numba.py: 53 warnings 957s groupby/aggregate/test_numba.py: 35 warnings 957s util/test_numba.py: 1 warning 957s window/moments/test_moments_consistency_ewm.py: 1088 warnings 957s window/moments/test_moments_consistency_expanding.py: 380 warnings 957s window/moments/test_moments_consistency_rolling.py: 760 warnings 957s window/test_api.py: 937 warnings 957s window/test_apply.py: 82 warnings 957s window/test_base_indexer.py: 228 warnings 957s window/test_cython_aggregations.py: 72 warnings 957s window/test_dtypes.py: 2580 warnings 957s window/test_ewm.py: 283 warnings 957s window/test_expanding.py: 333 warnings 957s window/test_groupby.py: 115 warnings 957s window/test_numba.py: 51 warnings 957s window/test_pairwise.py: 312 warnings 957s window/test_rolling.py: 888 warnings 957s window/test_rolling_functions.py: 418 warnings 957s window/test_rolling_quantile.py: 186 warnings 957s window/test_rolling_skew_kurt.py: 68 warnings 957s window/test_timeseries_window.py: 83 warnings 957s window/test_win_type.py: 287 warnings 957s /usr/lib/python3/dist-packages/py/_process/forkedfunc.py:45: DeprecationWarning: This process (pid=5709) is multi-threaded, use of fork() may lead to deadlocks in the child. 957s pid = os.fork() 957s 957s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 957s /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-q37i5mc0' 957s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 957s 957s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 957s /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-qtecampx' 957s session.config.cache.set(STEPWISE_CACHE_DIR, []) 957s 957s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 957s = 9060 passed, 793 skipped, 536 deselected, 59 xfailed, 9319 warnings in 204.25s (0:03:24) = 957s various xfailed tests - see xfail_tests_nonintel_io.patch, ignore_test_1094417_1088988.patch 957s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 957s 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" 957s 957s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 958s ============================= test session starts ============================== 958s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 958s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 958s rootdir: /usr/lib/python3/dist-packages/pandas/tests 958s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 958s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 958s collected 88 items / 3 skipped 958s 961s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py ....s..sssss.sF.........s. 963s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py ..F.............FF..F.sFFFFFF................................. 963s 963s =================================== FAILURES =================================== 963s __________________ test_frame_setitem_dask_array_into_new_col __________________ 963s @pytest.mark.xfail( 963s condition=True,#not IS64, 963s reason="ignoring https://bugs.debian.org/1094417 to unblock transition",#"dask has different nativesize-int vs int64 type rules", 963s strict=False, 963s ) 963s def test_frame_setitem_dask_array_into_new_col(): 963s # GH#47128 963s 963s # dask sets "compute.use_numexpr" to False, so catch the current value 963s # and ensure to reset it afterwards to avoid impacting other tests 963s olduse = pd.get_option("compute.use_numexpr") 963s 963s try: 963s da = td.versioned_importorskip("dask.array") 963s 963s dda = da.array([1, 2]) 963s df = DataFrame({"a": ["a", "b"]}) 963s df["b"] = dda 963s df["c"] = dda 963s df.loc[[False, True], "b"] = 100 963s result = df.loc[[1], :] 963s expected = DataFrame({"a": ["b"], "b": [100], "c": [2]}, index=[1]) 963s > tm.assert_frame_equal(result, expected) 963s 963s /usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:256: 963s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 963s 963s left = array([100]), right = array([2]), err_msg = None 963s 963s def _raise(left, right, err_msg) -> NoReturn: 963s if err_msg is None: 963s if left.shape != right.shape: 963s raise_assert_detail( 963s obj, f"{obj} shapes are different", left.shape, right.shape 963s ) 963s 963s diff = 0 963s for left_arr, right_arr in zip(left, right): 963s # count up differences 963s if not array_equivalent(left_arr, right_arr, strict_nan=strict_nan): 963s diff += 1 963s 963s diff = diff * 100.0 / left.size 963s msg = f"{obj} values are different ({np.round(diff, 5)} %)" 963s > raise_assert_detail(obj, msg, left, right, index_values=index_values) 963s E AssertionError: DataFrame.iloc[:, 2] (column name="c") are different 963s E 963s E DataFrame.iloc[:, 2] (column name="c") values are different (100.0 %) 963s E [index]: [1] 963s E [left]: [100] 963s E [right]: [2] 963s 963s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:684: AssertionError 963s ________ TestDataFrameToXArray.test_to_xarray_index_types[datetime-tz] _________ 963s self = 963s index_flat = DatetimeIndex(['2020-01-01 00:00:00-08:00', '2020-01-02 00:00:00-08:00', 963s '2020-01-03 00:00:00-08:00', '... '2020-04-08 00:00:00-07:00', '2020-04-09 00:00:00-07:00'], 963s dtype='datetime64[ns, US/Pacific]', freq='D') 963s df = bar a b c ... f g h 963s foo .....03 00:00:00-05:00 963s 2020-01-04 00:00:00-08:00 d 4 6 ... d 2013-01-04 2013-01-04 00:00:00-05:00 963s 963s [4 rows x 8 columns] 963s using_infer_string = False 963s 963s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 963s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 963s index = index_flat 963s # MultiIndex is tested in test_to_xarray_with_multiindex 963s if len(index) == 0: 963s pytest.skip("Test doesn't make sense for empty index") 963s 963s from xarray import Dataset 963s 963s df.index = index[:4] 963s df.index.name = "foo" 963s df.columns.name = "bar" 963s result = df.to_xarray() 963s assert result.sizes["foo"] == 4 963s assert len(result.coords) == 1 963s assert len(result.data_vars) == 8 963s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 963s assert isinstance(result, Dataset) 963s 963s # idempotency 963s # datetimes w/tz are preserved 963s # column names are lost 963s expected = df.copy() 963s # breaks in xarray >= 2024.10.0(?) 963s # debug print 963s r0 = result.to_dataframe() 963s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 963s expected.columns.name = None 963s > tm.assert_frame_equal(result.to_dataframe(), expected) 963s 963s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 963s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 963s 963s left = Index([2020-01-01 00:00:00-08:00, 2020-01-02 00:00:00-08:00, 963s 2020-01-03 00:00:00-08:00, 2020-01-04 00:00:00-08:00], 963s dtype='object', name='foo') 963s right = DatetimeIndex(['2020-01-01 00:00:00-08:00', '2020-01-02 00:00:00-08:00', 963s '2020-01-03 00:00:00-08:00', '2020-01-04 00:00:00-08:00'], 963s dtype='datetime64[ns, US/Pacific]', name='foo', freq='D') 963s obj = 'DataFrame.index' 963s 963s def _check_types(left, right, obj: str = "Index") -> None: 963s if not exact: 963s return 963s 963s > assert_class_equal(left, right, exact=exact, obj=obj) 963s E AssertionError: DataFrame.index are different 963s E 963s E DataFrame.index classes are different 963s E [left]: Index([2020-01-01 00:00:00-08:00, 2020-01-02 00:00:00-08:00, 963s E 2020-01-03 00:00:00-08:00, 2020-01-04 00:00:00-08:00], 963s E dtype='object', name='foo') 963s E [right]: DatetimeIndex(['2020-01-01 00:00:00-08:00', '2020-01-02 00:00:00-08:00', 963s E '2020-01-03 00:00:00-08:00', '2020-01-04 00:00:00-08:00'], 963s E dtype='datetime64[ns, US/Pacific]', name='foo', freq='D') 963s 963s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:235: AssertionError 963s ________ TestDataFrameToXArray.test_to_xarray_index_types[bool-object] _________ 963s self = 963s index_flat = Index([True, False, True, False, True, False, True, False, True, False], dtype='object') 963s df = bar a b c d e f g h 963s foo ... 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 963s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 963s using_infer_string = False 963s 963s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 963s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 963s index = index_flat 963s # MultiIndex is tested in test_to_xarray_with_multiindex 963s if len(index) == 0: 963s pytest.skip("Test doesn't make sense for empty index") 963s 963s from xarray import Dataset 963s 963s df.index = index[:4] 963s df.index.name = "foo" 963s df.columns.name = "bar" 963s result = df.to_xarray() 963s assert result.sizes["foo"] == 4 963s assert len(result.coords) == 1 963s assert len(result.data_vars) == 8 963s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 963s assert isinstance(result, Dataset) 963s 963s # idempotency 963s # datetimes w/tz are preserved 963s # column names are lost 963s expected = df.copy() 963s # breaks in xarray >= 2024.10.0(?) 963s # debug print 963s r0 = result.to_dataframe() 963s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 963s expected.columns.name = None 963s > tm.assert_frame_equal(result.to_dataframe(), expected) 963s E AssertionError: DataFrame are different 963s E 963s E DataFrame shape mismatch 963s E [left]: (8, 8) 963s E [right]: (4, 8) 963s 963s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: AssertionError 963s _________ TestDataFrameToXArray.test_to_xarray_index_types[bool-dtype] _________ 963s self = 963s index_flat = Index([True, False, True, False, True, False, True, False, True, False], dtype='bool') 963s df = bar a b c d e f g h 963s foo ... 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 963s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 963s using_infer_string = False 963s 963s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 963s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 963s index = index_flat 963s # MultiIndex is tested in test_to_xarray_with_multiindex 963s if len(index) == 0: 963s pytest.skip("Test doesn't make sense for empty index") 963s 963s from xarray import Dataset 963s 963s df.index = index[:4] 963s df.index.name = "foo" 963s df.columns.name = "bar" 963s result = df.to_xarray() 963s assert result.sizes["foo"] == 4 963s assert len(result.coords) == 1 963s assert len(result.data_vars) == 8 963s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 963s assert isinstance(result, Dataset) 963s 963s # idempotency 963s # datetimes w/tz are preserved 963s # column names are lost 963s expected = df.copy() 963s # breaks in xarray >= 2024.10.0(?) 963s # debug print 963s r0 = result.to_dataframe() 963s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 963s expected.columns.name = None 963s > tm.assert_frame_equal(result.to_dataframe(), expected) 963s E AssertionError: DataFrame are different 963s E 963s E DataFrame shape mismatch 963s E [left]: (8, 8) 963s E [right]: (4, 8) 963s 963s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: AssertionError 963s ________ TestDataFrameToXArray.test_to_xarray_index_types[categorical] _________ 963s self = 963s index_flat = CategoricalIndex(['a', 'b', 'c', 'd', 'a', 'b', 'c', 'd', 'a', 'b', 'c', 'd', 963s 'a', 'b', 'c', 'd', 'a... 'a', 'b', 'c', 'd'], 963s categories=['a', 'b', 'c', 'd'], ordered=False, dtype='category') 963s df = bar a b c d e f g h 963s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 963s d d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 963s using_infer_string = False 963s 963s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 963s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 963s index = index_flat 963s # MultiIndex is tested in test_to_xarray_with_multiindex 963s if len(index) == 0: 963s pytest.skip("Test doesn't make sense for empty index") 963s 963s from xarray import Dataset 963s 963s df.index = index[:4] 963s df.index.name = "foo" 963s df.columns.name = "bar" 963s result = df.to_xarray() 963s assert result.sizes["foo"] == 4 963s assert len(result.coords) == 1 963s assert len(result.data_vars) == 8 963s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 963s assert isinstance(result, Dataset) 963s 963s # idempotency 963s # datetimes w/tz are preserved 963s # column names are lost 963s expected = df.copy() 963s # breaks in xarray >= 2024.10.0(?) 963s # debug print 963s r0 = result.to_dataframe() 963s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 963s expected.columns.name = None 963s > tm.assert_frame_equal(result.to_dataframe(), expected) 963s 963s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 963s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 963s 963s left = Index(['a', 'b', 'c', 'd'], dtype='object', name='foo') 963s right = CategoricalIndex(['a', 'b', 'c', 'd'], categories=['a', 'b', 'c', 'd'], ordered=False, dtype='category', name='foo') 963s obj = 'DataFrame.index' 963s 963s def _check_types(left, right, obj: str = "Index") -> None: 963s if not exact: 963s return 963s 963s > assert_class_equal(left, right, exact=exact, obj=obj) 963s E AssertionError: DataFrame.index are different 963s E 963s E DataFrame.index classes are different 963s E [left]: Index(['a', 'b', 'c', 'd'], dtype='object', name='foo') 963s E [right]: CategoricalIndex(['a', 'b', 'c', 'd'], categories=['a', 'b', 'c', 'd'], ordered=False, dtype='category', name='foo') 963s 963s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:235: AssertionError 963s __________ TestDataFrameToXArray.test_to_xarray_index_types[repeats] ___________ 963s self = 963s index_flat = Index([0, 0, 1, 1, 2, 2], dtype='int64') 963s df = bar a b c d e f g h 963s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 963s 1 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 963s using_infer_string = False 963s 963s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 963s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 963s index = index_flat 963s # MultiIndex is tested in test_to_xarray_with_multiindex 963s if len(index) == 0: 963s pytest.skip("Test doesn't make sense for empty index") 963s 963s from xarray import Dataset 963s 963s df.index = index[:4] 963s df.index.name = "foo" 963s df.columns.name = "bar" 963s result = df.to_xarray() 963s assert result.sizes["foo"] == 4 963s assert len(result.coords) == 1 963s assert len(result.data_vars) == 8 963s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 963s assert isinstance(result, Dataset) 963s 963s # idempotency 963s # datetimes w/tz are preserved 963s # column names are lost 963s expected = df.copy() 963s # breaks in xarray >= 2024.10.0(?) 963s # debug print 963s r0 = result.to_dataframe() 963s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 963s expected.columns.name = None 963s > tm.assert_frame_equal(result.to_dataframe(), expected) 963s E AssertionError: DataFrame are different 963s E 963s E DataFrame shape mismatch 963s E [left]: (8, 8) 963s E [right]: (4, 8) 963s 963s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: AssertionError 963s ________ TestDataFrameToXArray.test_to_xarray_index_types[nullable_int] ________ 963s self = 963s index_flat = Index([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 963s 18, 19, 20, 21, 22, 23, 24, 25, ...7, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 963s 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 963s dtype='Int64') 963s df = bar a b c d e f g h 963s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 963s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 963s using_infer_string = False 963s 963s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 963s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 963s index = index_flat 963s # MultiIndex is tested in test_to_xarray_with_multiindex 963s if len(index) == 0: 963s pytest.skip("Test doesn't make sense for empty index") 963s 963s from xarray import Dataset 963s 963s df.index = index[:4] 963s df.index.name = "foo" 963s df.columns.name = "bar" 963s result = df.to_xarray() 963s assert result.sizes["foo"] == 4 963s assert len(result.coords) == 1 963s assert len(result.data_vars) == 8 963s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 963s assert isinstance(result, Dataset) 963s 963s # idempotency 963s # datetimes w/tz are preserved 963s # column names are lost 963s expected = df.copy() 963s # breaks in xarray >= 2024.10.0(?) 963s # debug print 963s r0 = result.to_dataframe() 963s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 963s expected.columns.name = None 963s > tm.assert_frame_equal(result.to_dataframe(), expected) 963s 963s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 963s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 963s 963s left = Index([0, 1, 2, 3], dtype='object', name='foo') 963s right = Index([0, 1, 2, 3], dtype='Int64', name='foo'), obj = 'DataFrame.index' 963s 963s def _check_types(left, right, obj: str = "Index") -> None: 963s if not exact: 963s return 963s 963s assert_class_equal(left, right, exact=exact, obj=obj) 963s assert_attr_equal("inferred_type", left, right, obj=obj) 963s 963s # Skip exact dtype checking when `check_categorical` is False 963s if isinstance(left.dtype, CategoricalDtype) and isinstance( 963s right.dtype, CategoricalDtype 963s ): 963s if check_categorical: 963s assert_attr_equal("dtype", left, right, obj=obj) 963s assert_index_equal(left.categories, right.categories, exact=exact) 963s return 963s 963s > assert_attr_equal("dtype", left, right, obj=obj) 963s E AssertionError: DataFrame.index are different 963s E 963s E Attribute "dtype" are different 963s E [left]: object 963s E [right]: Int64 963s 963s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:247: AssertionError 963s _______ TestDataFrameToXArray.test_to_xarray_index_types[nullable_uint] ________ 963s self = 963s index_flat = Index([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 963s 18, 19, 20, 21, 22, 23, 24, 25, ..., 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 963s 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 963s dtype='UInt16') 963s df = bar a b c d e f g h 963s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 963s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 963s using_infer_string = False 963s 963s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 963s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 963s index = index_flat 963s # MultiIndex is tested in test_to_xarray_with_multiindex 963s if len(index) == 0: 963s pytest.skip("Test doesn't make sense for empty index") 963s 963s from xarray import Dataset 963s 963s df.index = index[:4] 963s df.index.name = "foo" 963s df.columns.name = "bar" 963s result = df.to_xarray() 963s assert result.sizes["foo"] == 4 963s assert len(result.coords) == 1 963s assert len(result.data_vars) == 8 963s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 963s assert isinstance(result, Dataset) 963s 963s # idempotency 963s # datetimes w/tz are preserved 963s # column names are lost 963s expected = df.copy() 963s # breaks in xarray >= 2024.10.0(?) 963s # debug print 963s r0 = result.to_dataframe() 963s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 963s expected.columns.name = None 963s > tm.assert_frame_equal(result.to_dataframe(), expected) 963s 963s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 963s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 963s 963s left = Index([0, 1, 2, 3], dtype='object', name='foo') 963s right = Index([0, 1, 2, 3], dtype='UInt16', name='foo'), obj = 'DataFrame.index' 963s 963s def _check_types(left, right, obj: str = "Index") -> None: 963s if not exact: 963s return 963s 963s assert_class_equal(left, right, exact=exact, obj=obj) 963s assert_attr_equal("inferred_type", left, right, obj=obj) 963s 963s # Skip exact dtype checking when `check_categorical` is False 963s if isinstance(left.dtype, CategoricalDtype) and isinstance( 963s right.dtype, CategoricalDtype 963s ): 963s if check_categorical: 963s assert_attr_equal("dtype", left, right, obj=obj) 963s assert_index_equal(left.categories, right.categories, exact=exact) 963s return 963s 963s > assert_attr_equal("dtype", left, right, obj=obj) 963s E AssertionError: DataFrame.index are different 963s E 963s E Attribute "dtype" are different 963s E [left]: object 963s E [right]: UInt16 963s 963s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:247: AssertionError 963s _______ TestDataFrameToXArray.test_to_xarray_index_types[nullable_float] _______ 963s self = 963s 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, 963s 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, 963s 96.0, 97.0, 98.0, 99.0], 963s dtype='Float32') 963s df = bar a b c d e f g h 963s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 963s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 963s using_infer_string = False 963s 963s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 963s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 963s index = index_flat 963s # MultiIndex is tested in test_to_xarray_with_multiindex 963s if len(index) == 0: 963s pytest.skip("Test doesn't make sense for empty index") 963s 963s from xarray import Dataset 963s 963s df.index = index[:4] 963s df.index.name = "foo" 963s df.columns.name = "bar" 963s result = df.to_xarray() 963s assert result.sizes["foo"] == 4 963s assert len(result.coords) == 1 963s assert len(result.data_vars) == 8 963s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 963s assert isinstance(result, Dataset) 963s 963s # idempotency 963s # datetimes w/tz are preserved 963s # column names are lost 963s expected = df.copy() 963s # breaks in xarray >= 2024.10.0(?) 963s # debug print 963s r0 = result.to_dataframe() 963s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 963s expected.columns.name = None 963s > tm.assert_frame_equal(result.to_dataframe(), expected) 963s 963s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 963s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 963s 963s left = Index([0.0, 1.0, 2.0, 3.0], dtype='object', name='foo') 963s right = Index([0.0, 1.0, 2.0, 3.0], dtype='Float32', name='foo') 963s obj = 'DataFrame.index' 963s 963s def _check_types(left, right, obj: str = "Index") -> None: 963s if not exact: 963s return 963s 963s assert_class_equal(left, right, exact=exact, obj=obj) 963s assert_attr_equal("inferred_type", left, right, obj=obj) 963s 963s # Skip exact dtype checking when `check_categorical` is False 963s if isinstance(left.dtype, CategoricalDtype) and isinstance( 963s right.dtype, CategoricalDtype 963s ): 963s if check_categorical: 963s assert_attr_equal("dtype", left, right, obj=obj) 963s assert_index_equal(left.categories, right.categories, exact=exact) 963s return 963s 963s > assert_attr_equal("dtype", left, right, obj=obj) 963s E AssertionError: DataFrame.index are different 963s E 963s E Attribute "dtype" are different 963s E [left]: object 963s E [right]: Float32 963s 963s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:247: AssertionError 963s _______ TestDataFrameToXArray.test_to_xarray_index_types[nullable_bool] ________ 963s self = 963s index_flat = Index([False, True, True, True, True, True, True, True, True, True, 963s True, True, True, True, True,...rue, True, True, 963s True, True, True, True, True, True, True, True, True, True], 963s dtype='boolean') 963s df = bar a b c d e f g h 963s foo ... 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 963s True d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 963s using_infer_string = False 963s 963s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 963s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 963s index = index_flat 963s # MultiIndex is tested in test_to_xarray_with_multiindex 963s if len(index) == 0: 963s pytest.skip("Test doesn't make sense for empty index") 963s 963s from xarray import Dataset 963s 963s df.index = index[:4] 963s df.index.name = "foo" 963s df.columns.name = "bar" 963s result = df.to_xarray() 963s assert result.sizes["foo"] == 4 963s assert len(result.coords) == 1 963s assert len(result.data_vars) == 8 963s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 963s assert isinstance(result, Dataset) 963s 963s # idempotency 963s # datetimes w/tz are preserved 963s # column names are lost 963s expected = df.copy() 963s # breaks in xarray >= 2024.10.0(?) 963s # debug print 963s r0 = result.to_dataframe() 963s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 963s expected.columns.name = None 963s > tm.assert_frame_equal(result.to_dataframe(), expected) 963s E AssertionError: DataFrame are different 963s E 963s E DataFrame shape mismatch 963s E [left]: (10, 8) 963s E [right]: (4, 8) 963s 963s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: AssertionError 963s _______ TestDataFrameToXArray.test_to_xarray_index_types[string-python] ________ 963s self = 963s index_flat = Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3', 'pandas_4', 'pandas_5', 963s 'pandas_6', 'pandas_7', 'pandas_...pandas_93', 'pandas_94', 'pandas_95', 963s 'pandas_96', 'pandas_97', 'pandas_98', 'pandas_99'], 963s dtype='string') 963s df = bar a b c d e f g h 963s foo ....0 True c 2013-01-03 2013-01-03 00:00:00-05:00 963s pandas_3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 963s using_infer_string = False 963s 963s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 963s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 963s index = index_flat 963s # MultiIndex is tested in test_to_xarray_with_multiindex 963s if len(index) == 0: 963s pytest.skip("Test doesn't make sense for empty index") 963s 963s from xarray import Dataset 963s 963s df.index = index[:4] 963s df.index.name = "foo" 963s df.columns.name = "bar" 963s result = df.to_xarray() 963s assert result.sizes["foo"] == 4 963s assert len(result.coords) == 1 963s assert len(result.data_vars) == 8 963s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 963s assert isinstance(result, Dataset) 963s 963s # idempotency 963s # datetimes w/tz are preserved 963s # column names are lost 963s expected = df.copy() 963s # breaks in xarray >= 2024.10.0(?) 963s # debug print 963s r0 = result.to_dataframe() 963s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 963s expected.columns.name = None 963s > tm.assert_frame_equal(result.to_dataframe(), expected) 963s 963s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 963s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 963s 963s left = Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='object', name='foo') 963s right = Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='string', name='foo') 963s obj = 'DataFrame.index' 963s 963s def _check_types(left, right, obj: str = "Index") -> None: 963s if not exact: 963s return 963s 963s assert_class_equal(left, right, exact=exact, obj=obj) 963s assert_attr_equal("inferred_type", left, right, obj=obj) 963s 963s # Skip exact dtype checking when `check_categorical` is False 963s if isinstance(left.dtype, CategoricalDtype) and isinstance( 963s right.dtype, CategoricalDtype 963s ): 963s if check_categorical: 963s assert_attr_equal("dtype", left, right, obj=obj) 963s assert_index_equal(left.categories, right.categories, exact=exact) 963s return 963s 963s > assert_attr_equal("dtype", left, right, obj=obj) 963s E AssertionError: DataFrame.index are different 963s E 963s E Attribute "dtype" are different 963s E [left]: object 963s E [right]: string[python] 963s 963s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:247: AssertionError 963s =============================== warnings summary =============================== 963s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:119 963s /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 963s @pytest.mark.single_cpu 963s 963s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:125 963s /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 963s @pytest.mark.single_cpu 963s 963s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:196 963s /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 963s @pytest.mark.single_cpu 963s 963s test_downstream.py: 26 warnings 963s generic/test_to_xarray.py: 62 warnings 963s /usr/lib/python3/dist-packages/py/_process/forkedfunc.py:45: DeprecationWarning: This process (pid=15644) is multi-threaded, use of fork() may lead to deadlocks in the child. 963s pid = os.fork() 963s 963s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 963s /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-wmz48rru' 963s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 963s 963s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:429 963s /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-6h88l3n2' 963s config.cache.set("cache/lastfailed", self.lastfailed) 963s 963s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 963s /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-wvyrdu3w' 963s session.config.cache.set(STEPWISE_CACHE_DIR, []) 963s 963s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 963s =========================== short test summary info ============================ 963s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py::test_frame_setitem_dask_array_into_new_col 963s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[datetime-tz] 963s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[bool-object] 963s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[bool-dtype] 963s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[categorical] 963s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[repeats] 963s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_int] 963s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_uint] 963s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_float] 963s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_bool] 963s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[string-python] 963s ============ 11 failed, 68 passed, 12 skipped, 94 warnings in 5.52s ============ 963s pymysql/psycopg2 tests, which do not work in this test environment 964s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 964s 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" 964s 964s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 964s ============================= test session starts ============================== 964s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 964s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 964s rootdir: /usr/lib/python3/dist-packages/pandas/tests 964s plugins: xdist-3.6.1, forked-1.6.0, localserver-0.9.0.post0, hypothesis-6.127.4, typeguard-4.4.2, qt-4.4.0, asyncio-0.25.1 964s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 964s collected 2513 items 964s 1414s ../../../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................ 1427s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_datetime.py ..................................................................................................................................................................................................................................ssssssss......................................................................................................................................................................................................................................................................................................................................................xx..........................................................................................................................................................................................................................................................................................................................................................................ssssssssss............................ 1427s 1427s ==================================== ERRORS ==================================== 1427s _______ ERROR at teardown of test_dataframe_to_sql[mysql_pymysql_engine] _______ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s ________ ERROR at teardown of test_dataframe_to_sql[mysql_pymysql_conn] ________ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s ____ ERROR at teardown of test_dataframe_to_sql[postgresql_psycopg2_engine] ____ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _____ ERROR at teardown of test_dataframe_to_sql[postgresql_psycopg2_conn] _____ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s ____ ERROR at teardown of test_dataframe_to_sql_empty[mysql_pymysql_engine] ____ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _____ ERROR at teardown of test_dataframe_to_sql_empty[mysql_pymysql_conn] _____ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_dataframe_to_sql_empty[postgresql_psycopg2_engine] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s __ ERROR at teardown of test_dataframe_to_sql_empty[postgresql_psycopg2_conn] __ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _________ ERROR at teardown of test_to_sql[None-mysql_pymysql_engine] __________ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s __________ ERROR at teardown of test_to_sql[None-mysql_pymysql_conn] ___________ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s ______ ERROR at teardown of test_to_sql[None-postgresql_psycopg2_engine] _______ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _______ ERROR at teardown of test_to_sql[None-postgresql_psycopg2_conn] ________ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _________ ERROR at teardown of test_to_sql[multi-mysql_pymysql_engine] _________ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s __________ ERROR at teardown of test_to_sql[multi-mysql_pymysql_conn] __________ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s ______ ERROR at teardown of test_to_sql[multi-postgresql_psycopg2_engine] ______ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _______ ERROR at teardown of test_to_sql[multi-postgresql_psycopg2_conn] _______ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s ____ ERROR at teardown of test_to_sql_exist[replace-1-mysql_pymysql_engine] ____ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _____ ERROR at teardown of test_to_sql_exist[replace-1-mysql_pymysql_conn] _____ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_to_sql_exist[replace-1-postgresql_psycopg2_engine] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s __ ERROR at teardown of test_to_sql_exist[replace-1-postgresql_psycopg2_conn] __ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s ____ ERROR at teardown of test_to_sql_exist[append-2-mysql_pymysql_engine] _____ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _____ ERROR at teardown of test_to_sql_exist[append-2-mysql_pymysql_conn] ______ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_to_sql_exist[append-2-postgresql_psycopg2_engine] __ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s __ ERROR at teardown of test_to_sql_exist[append-2-postgresql_psycopg2_conn] ___ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s ______ ERROR at teardown of test_to_sql_exist_fail[mysql_pymysql_engine] _______ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _______ ERROR at teardown of test_to_sql_exist_fail[mysql_pymysql_conn] ________ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s ___ ERROR at teardown of test_to_sql_exist_fail[postgresql_psycopg2_engine] ____ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s ____ ERROR at teardown of test_to_sql_exist_fail[postgresql_psycopg2_conn] _____ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _____ ERROR at teardown of test_read_iris_query[mysql_pymysql_engine_iris] _____ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s ______ ERROR at teardown of test_read_iris_query[mysql_pymysql_conn_iris] ______ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s __ ERROR at teardown of test_read_iris_query[postgresql_psycopg2_engine_iris] __ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s ___ ERROR at teardown of test_read_iris_query[postgresql_psycopg2_conn_iris] ___ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_read_iris_query_chunksize[mysql_pymysql_engine_iris] _ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_read_iris_query_chunksize[mysql_pymysql_conn_iris] _ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_read_iris_query_chunksize[postgresql_psycopg2_engine_iris] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_read_iris_query_chunksize[postgresql_psycopg2_conn_iris] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_read_iris_query_expression_with_parameter[mysql_pymysql_engine_iris] _ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_read_iris_query_expression_with_parameter[mysql_pymysql_conn_iris] _ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_read_iris_query_expression_with_parameter[postgresql_psycopg2_engine_iris] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_read_iris_query_expression_with_parameter[postgresql_psycopg2_conn_iris] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_read_iris_query_string_with_parameter[mysql_pymysql_engine_iris] _ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_read_iris_query_string_with_parameter[mysql_pymysql_conn_iris] _ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_read_iris_query_string_with_parameter[postgresql_psycopg2_engine_iris] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_read_iris_query_string_with_parameter[postgresql_psycopg2_conn_iris] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _____ ERROR at teardown of test_read_iris_table[mysql_pymysql_engine_iris] _____ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s ______ ERROR at teardown of test_read_iris_table[mysql_pymysql_conn_iris] ______ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s __ ERROR at teardown of test_read_iris_table[postgresql_psycopg2_engine_iris] __ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s ___ ERROR at teardown of test_read_iris_table[postgresql_psycopg2_conn_iris] ___ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_read_iris_table_chunksize[mysql_pymysql_engine_iris] _ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_read_iris_table_chunksize[mysql_pymysql_conn_iris] _ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_read_iris_table_chunksize[postgresql_psycopg2_engine_iris] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_read_iris_table_chunksize[postgresql_psycopg2_conn_iris] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _______ ERROR at teardown of test_to_sql_callable[mysql_pymysql_engine] ________ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s ________ ERROR at teardown of test_to_sql_callable[mysql_pymysql_conn] _________ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s ____ ERROR at teardown of test_to_sql_callable[postgresql_psycopg2_engine] _____ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _____ ERROR at teardown of test_to_sql_callable[postgresql_psycopg2_conn] ______ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_default_type_conversion[mysql_pymysql_engine_types] _ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_default_type_conversion[mysql_pymysql_conn_types] __ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_default_type_conversion[postgresql_psycopg2_engine_types] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_default_type_conversion[postgresql_psycopg2_conn_types] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s ________ ERROR at teardown of test_read_procedure[mysql_pymysql_engine] ________ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _________ ERROR at teardown of test_read_procedure[mysql_pymysql_conn] _________ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_copy_from_callable_insertion_method[2-postgresql_psycopg2_engine] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_copy_from_callable_insertion_method[2-postgresql_psycopg2_conn] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_engine] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_conn] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_engine] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_conn] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_to_sql_on_public_schema[postgresql_psycopg2_engine] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_to_sql_on_public_schema[postgresql_psycopg2_conn] __ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_insertion_method_on_conflict_update[mysql_pymysql_engine] _ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_insertion_method_on_conflict_update[mysql_pymysql_conn] _ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s ___ ERROR at teardown of test_read_view_postgres[postgresql_psycopg2_engine] ___ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s ____ ERROR at teardown of test_read_view_postgres[postgresql_psycopg2_conn] ____ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_read_sql_iris_parameter[mysql_pymysql_engine_iris] _ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s __ ERROR at teardown of test_read_sql_iris_parameter[mysql_pymysql_conn_iris] __ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_read_sql_iris_parameter[postgresql_psycopg2_engine_iris] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_read_sql_iris_parameter[postgresql_psycopg2_conn_iris] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_read_sql_iris_named_parameter[mysql_pymysql_engine_iris] _ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_read_sql_iris_named_parameter[mysql_pymysql_conn_iris] _ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_read_sql_iris_named_parameter[postgresql_psycopg2_engine_iris] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_read_sql_iris_named_parameter[postgresql_psycopg2_conn_iris] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s ____ ERROR at teardown of test_api_read_sql_view[mysql_pymysql_engine_iris] ____ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _____ ERROR at teardown of test_api_read_sql_view[mysql_pymysql_conn_iris] _____ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_api_read_sql_view[postgresql_psycopg2_engine_iris] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s __ ERROR at teardown of test_api_read_sql_view[postgresql_psycopg2_conn_iris] __ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_api_read_sql_with_chunksize_no_result[mysql_pymysql_engine_iris] _ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_api_read_sql_with_chunksize_no_result[mysql_pymysql_conn_iris] _ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_engine_iris] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_conn_iris] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s __________ ERROR at teardown of test_api_to_sql[mysql_pymysql_engine] __________ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s ___________ ERROR at teardown of test_api_to_sql[mysql_pymysql_conn] ___________ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _______ ERROR at teardown of test_api_to_sql[postgresql_psycopg2_engine] _______ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s ________ ERROR at teardown of test_api_to_sql[postgresql_psycopg2_conn] ________ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _______ ERROR at teardown of test_api_to_sql_fail[mysql_pymysql_engine] ________ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s ________ ERROR at teardown of test_api_to_sql_fail[mysql_pymysql_conn] _________ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s ____ ERROR at teardown of test_api_to_sql_fail[postgresql_psycopg2_engine] _____ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _____ ERROR at teardown of test_api_to_sql_fail[postgresql_psycopg2_conn] ______ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s ______ ERROR at teardown of test_api_to_sql_replace[mysql_pymysql_engine] ______ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _______ ERROR at teardown of test_api_to_sql_replace[mysql_pymysql_conn] _______ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s ___ ERROR at teardown of test_api_to_sql_replace[postgresql_psycopg2_engine] ___ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s ____ ERROR at teardown of test_api_to_sql_replace[postgresql_psycopg2_conn] ____ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s ______ ERROR at teardown of test_api_to_sql_append[mysql_pymysql_engine] _______ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _______ ERROR at teardown of test_api_to_sql_append[mysql_pymysql_conn] ________ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s ___ ERROR at teardown of test_api_to_sql_append[postgresql_psycopg2_engine] ____ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s ____ ERROR at teardown of test_api_to_sql_append[postgresql_psycopg2_conn] _____ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s ___ ERROR at teardown of test_api_to_sql_type_mapping[mysql_pymysql_engine] ____ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s ____ ERROR at teardown of test_api_to_sql_type_mapping[mysql_pymysql_conn] _____ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_api_to_sql_type_mapping[postgresql_psycopg2_engine] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_api_to_sql_type_mapping[postgresql_psycopg2_conn] __ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s ______ ERROR at teardown of test_api_to_sql_series[mysql_pymysql_engine] _______ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _______ ERROR at teardown of test_api_to_sql_series[mysql_pymysql_conn] ________ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s ___ ERROR at teardown of test_api_to_sql_series[postgresql_psycopg2_engine] ____ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s ____ ERROR at teardown of test_api_to_sql_series[postgresql_psycopg2_conn] _____ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s ________ ERROR at teardown of test_api_roundtrip[mysql_pymysql_engine] _________ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _________ ERROR at teardown of test_api_roundtrip[mysql_pymysql_conn] __________ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _____ ERROR at teardown of test_api_roundtrip[postgresql_psycopg2_engine] ______ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s ______ ERROR at teardown of test_api_roundtrip[postgresql_psycopg2_conn] _______ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s ___ ERROR at teardown of test_api_roundtrip_chunksize[mysql_pymysql_engine] ____ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s ____ ERROR at teardown of test_api_roundtrip_chunksize[mysql_pymysql_conn] _____ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_api_roundtrip_chunksize[postgresql_psycopg2_engine] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_api_roundtrip_chunksize[postgresql_psycopg2_conn] __ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _____ ERROR at teardown of test_api_execute_sql[mysql_pymysql_engine_iris] _____ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s ______ ERROR at teardown of test_api_execute_sql[mysql_pymysql_conn_iris] ______ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s __ ERROR at teardown of test_api_execute_sql[postgresql_psycopg2_engine_iris] __ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s ___ ERROR at teardown of test_api_execute_sql[postgresql_psycopg2_conn_iris] ___ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s ____ ERROR at teardown of test_api_date_parsing[mysql_pymysql_engine_types] ____ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _____ ERROR at teardown of test_api_date_parsing[mysql_pymysql_conn_types] _____ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_api_date_parsing[postgresql_psycopg2_engine_types] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s __ ERROR at teardown of test_api_date_parsing[postgresql_psycopg2_conn_types] __ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_engine_types] _ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_conn_types] _ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_engine_types] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_conn_types] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_engine_types] _ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_conn_types] _ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_engine_types] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_conn_types] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_engine_types] _ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_conn_types] _ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_engine_types] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_conn_types] _ 1427s self = 1427s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1427s connection = None, _has_events = None, _allow_revalidate = True 1427s _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def postgresql_psycopg2_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s td.versioned_importorskip("psycopg2") 1427s engine = sqlalchemy.create_engine( 1427s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1427s connection_factory = None, cursor_factory = None 1427s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1427s kwasync = {} 1427s 1427s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1427s """ 1427s Create a new database connection. 1427s 1427s The connection parameters can be specified as a string: 1427s 1427s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1427s 1427s or using a set of keyword arguments: 1427s 1427s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1427s 1427s Or as a mix of both. The basic connection parameters are: 1427s 1427s - *dbname*: the database name 1427s - *database*: the database name (only as keyword argument) 1427s - *user*: user name used to authenticate 1427s - *password*: password used to authenticate 1427s - *host*: database host address (defaults to UNIX socket if not provided) 1427s - *port*: connection port number (defaults to 5432 if not provided) 1427s 1427s Using the *connection_factory* parameter a different class or connections 1427s factory can be specified. It should be a callable object taking a dsn 1427s argument. 1427s 1427s Using the *cursor_factory* parameter, a new default cursor factory will be 1427s used by cursor(). 1427s 1427s Using *async*=True an asynchronous connection will be created. *async_* is 1427s a valid alias (for Python versions where ``async`` is a keyword). 1427s 1427s Any other keyword parameter will be passed to the underlying client 1427s library: the list of supported parameters depends on the library version. 1427s 1427s """ 1427s kwasync = {} 1427s if 'async' in kwargs: 1427s kwasync['async'] = kwargs.pop('async') 1427s if 'async_' in kwargs: 1427s kwasync['async_'] = kwargs.pop('async_') 1427s 1427s dsn = _ext.make_dsn(dsn, **kwargs) 1427s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1427s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1427s E Is the server running on that host and accepting TCP/IP connections? 1427s E 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1427s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_engine_types] _ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_conn_types] _ 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s > sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3.13/socket.py:864: in create_connection 1427s raise exceptions[0] 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s address = ('localhost', 3306), timeout = 10, source_address = None 1427s 1427s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1427s source_address=None, *, all_errors=False): 1427s """Connect to *address* and return the socket object. 1427s 1427s Convenience function. Connect to *address* (a 2-tuple ``(host, 1427s port)``) and return the socket object. Passing the optional 1427s *timeout* parameter will set the timeout on the socket instance 1427s before attempting to connect. If no *timeout* is supplied, the 1427s global default timeout setting returned by :func:`getdefaulttimeout` 1427s is used. If *source_address* is set it must be a tuple of (host, port) 1427s for the socket to bind as a source address before making the connection. 1427s A host of '' or port 0 tells the OS to use the default. When a connection 1427s cannot be created, raises the last error if *all_errors* is False, 1427s and an ExceptionGroup of all errors if *all_errors* is True. 1427s """ 1427s 1427s host, port = address 1427s exceptions = [] 1427s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1427s af, socktype, proto, canonname, sa = res 1427s sock = None 1427s try: 1427s sock = socket(af, socktype, proto) 1427s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1427s sock.settimeout(timeout) 1427s if source_address: 1427s sock.bind(source_address) 1427s > sock.connect(sa) 1427s E ConnectionRefusedError: [Errno 111] Connection refused 1427s 1427s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1427s 1427s During handling of the above exception, another exception occurred: 1427s 1427s self = 1427s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1427s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1427s 1427s def __init__( 1427s self, 1427s engine: Engine, 1427s connection: Optional[PoolProxiedConnection] = None, 1427s _has_events: Optional[bool] = None, 1427s _allow_revalidate: bool = True, 1427s _allow_autobegin: bool = True, 1427s ): 1427s """Construct a new Connection.""" 1427s self.engine = engine 1427s self.dialect = dialect = engine.dialect 1427s 1427s if connection is None: 1427s try: 1427s > self._dbapi_connection = engine.raw_connection() 1427s 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1427s return _ConnectionFairy._checkout(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1427s fairy = _ConnectionRecord.checkout(pool) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1427s rec = pool._do_get() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1427s return self._create_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1427s return _ConnectionRecord(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1427s self.__connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1427s with util.safe_reraise(): 1427s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1427s raise exc_value.with_traceback(exc_tb) 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1427s self.dbapi_connection = connection = pool._invoke_creator(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1427s return dialect.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1427s return self.loaded_dbapi.connect(*cargs, **cparams) 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1427s self.connect() 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s 1427s self = , sock = None 1427s 1427s def connect(self, sock=None): 1427s self._closed = False 1427s try: 1427s if sock is None: 1427s if self.unix_socket: 1427s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1427s sock.settimeout(self.connect_timeout) 1427s sock.connect(self.unix_socket) 1427s self.host_info = "Localhost via UNIX socket" 1427s self._secure = True 1427s if DEBUG: 1427s print("connected using unix_socket") 1427s else: 1427s kwargs = {} 1427s if self.bind_address is not None: 1427s kwargs["source_address"] = (self.bind_address, 0) 1427s while True: 1427s try: 1427s sock = socket.create_connection( 1427s (self.host, self.port), self.connect_timeout, **kwargs 1427s ) 1427s break 1427s except OSError as e: 1427s if e.errno == errno.EINTR: 1427s continue 1427s raise 1427s self.host_info = "socket %s:%d" % (self.host, self.port) 1427s if DEBUG: 1427s print("connected using socket") 1427s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1427s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1427s sock.settimeout(None) 1427s 1427s self._sock = sock 1427s self._rfile = sock.makefile("rb") 1427s self._next_seq_id = 0 1427s 1427s self._get_server_information() 1427s self._request_authentication() 1427s 1427s # Send "SET NAMES" query on init for: 1427s # - Ensure charaset (and collation) is set to the server. 1427s # - collation_id in handshake packet may be ignored. 1427s # - If collation is not specified, we don't know what is server's 1427s # default collation for the charset. For example, default collation 1427s # of utf8mb4 is: 1427s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1427s # - MySQL 8.0: utf8mb4_0900_ai_ci 1427s # 1427s # Reference: 1427s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1427s # - https://github.com/wagtail/wagtail/issues/9477 1427s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1427s self.set_character_set(self.charset, self.collation) 1427s 1427s if self.sql_mode is not None: 1427s c = self.cursor() 1427s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1427s c.close() 1427s 1427s if self.init_command is not None: 1427s c = self.cursor() 1427s c.execute(self.init_command) 1427s c.close() 1427s 1427s if self.autocommit_mode is not None: 1427s self.autocommit(self.autocommit_mode) 1427s except BaseException as e: 1427s self._rfile = None 1427s if sock is not None: 1427s try: 1427s sock.close() 1427s except: # noqa 1427s pass 1427s 1427s if isinstance(e, (OSError, IOError)): 1427s exc = err.OperationalError( 1427s CR.CR_CONN_HOST_ERROR, 1427s f"Can't connect to MySQL server on {self.host!r} ({e})", 1427s ) 1427s # Keep original exception and traceback to investigate error. 1427s exc.original_exception = e 1427s exc.traceback = traceback.format_exc() 1427s if DEBUG: 1427s print(exc.traceback) 1427s > raise exc 1427s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1427s 1427s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1427s 1427s The above exception was the direct cause of the following exception: 1427s 1427s @pytest.fixture 1427s def mysql_pymysql_engine(): 1427s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1427s pymysql = td.versioned_importorskip("pymysql") 1427s engine = sqlalchemy.create_engine( 1427s "mysql+pymysql://root@localhost:3306/pandas", 1427s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1427s poolclass=sqlalchemy.pool.NullPool, 1427s ) 1427s yield engine 1427s > for view in get_all_views(engine): 1427s 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1427s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1427s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1427s return inspect(conn).get_view_names() 1427s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1427s ret = reg(subject) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1427s return Inspector._construct(Inspector._init_engine, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1427s init(self, bind) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1427s engine.connect().close() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1427s return self._connection_cls(self) 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1427s Connection._handle_dbapi_exception_noconnection( 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1427s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1427s self._dbapi_connection = engine.raw_connection() 1427s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1427s return self.pool.connect() 1427s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_engine_types] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_conn_types] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_engine_types] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_conn_types] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_engine_types] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_conn_types] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_engine_types] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_conn_types] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_engine_types] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_conn_types] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_engine_types] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_conn_types] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_engine_types] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_conn_types] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_engine_types] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_conn_types] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_engine_types] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_conn_types] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_engine_types] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_conn_types] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_engine_types] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_conn_types] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s ___ ERROR at teardown of test_api_date_and_index[mysql_pymysql_engine_types] ___ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s ____ ERROR at teardown of test_api_date_and_index[mysql_pymysql_conn_types] ____ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_date_and_index[postgresql_psycopg2_engine_types] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_date_and_index[postgresql_psycopg2_conn_types] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s ________ ERROR at teardown of test_api_timedelta[mysql_pymysql_engine] _________ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _________ ERROR at teardown of test_api_timedelta[mysql_pymysql_conn] __________ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _____ ERROR at teardown of test_api_timedelta[postgresql_psycopg2_engine] ______ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s ______ ERROR at teardown of test_api_timedelta[postgresql_psycopg2_conn] _______ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s ______ ERROR at teardown of test_api_complex_raises[mysql_pymysql_engine] ______ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _______ ERROR at teardown of test_api_complex_raises[mysql_pymysql_conn] _______ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s ___ ERROR at teardown of test_api_complex_raises[postgresql_psycopg2_engine] ___ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s ____ ERROR at teardown of test_api_complex_raises[postgresql_psycopg2_conn] ____ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_to_sql_index_label[None-None-index-mysql_pymysql_engine] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_to_sql_index_label[None-None-index-mysql_pymysql_conn] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_engine] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_conn] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_engine] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_conn] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_engine] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_conn] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_to_sql_index_label[0-None-0-mysql_pymysql_engine] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_to_sql_index_label[0-None-0-mysql_pymysql_conn] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_to_sql_index_label[None-0-0-mysql_pymysql_engine] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_to_sql_index_label[None-0-0-mysql_pymysql_conn] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_to_sql_index_label_multiindex[postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_to_sql_index_label_multiindex[postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s ___ ERROR at teardown of test_api_multiindex_roundtrip[mysql_pymysql_engine] ___ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s ____ ERROR at teardown of test_api_multiindex_roundtrip[mysql_pymysql_conn] ____ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_multiindex_roundtrip[postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_multiindex_roundtrip[postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s ___ ERROR at teardown of test_api_dtype_argument[None-mysql_pymysql_engine] ____ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s ____ ERROR at teardown of test_api_dtype_argument[None-mysql_pymysql_conn] _____ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_dtype_argument[None-postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_dtype_argument[None-postgresql_psycopg2_conn] __ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s ____ ERROR at teardown of test_api_dtype_argument[int-mysql_pymysql_engine] ____ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _____ ERROR at teardown of test_api_dtype_argument[int-mysql_pymysql_conn] _____ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_dtype_argument[int-postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s __ ERROR at teardown of test_api_dtype_argument[int-postgresql_psycopg2_conn] __ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s ___ ERROR at teardown of test_api_dtype_argument[float-mysql_pymysql_engine] ___ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s ____ ERROR at teardown of test_api_dtype_argument[float-mysql_pymysql_conn] ____ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_dtype_argument[float-postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_dtype_argument[float-postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s __ ERROR at teardown of test_api_dtype_argument[dtype3-mysql_pymysql_engine] ___ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s ___ ERROR at teardown of test_api_dtype_argument[dtype3-mysql_pymysql_conn] ____ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_dtype_argument[dtype3-postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_dtype_argument[dtype3-postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s ____ ERROR at teardown of test_api_integer_col_names[mysql_pymysql_engine] _____ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _____ ERROR at teardown of test_api_integer_col_names[mysql_pymysql_conn] ______ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_integer_col_names[postgresql_psycopg2_engine] __ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s __ ERROR at teardown of test_api_integer_col_names[postgresql_psycopg2_conn] ___ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s ________ ERROR at teardown of test_api_get_schema[mysql_pymysql_engine] ________ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _________ ERROR at teardown of test_api_get_schema[mysql_pymysql_conn] _________ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _____ ERROR at teardown of test_api_get_schema[postgresql_psycopg2_engine] _____ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s ______ ERROR at teardown of test_api_get_schema[postgresql_psycopg2_conn] ______ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s __ ERROR at teardown of test_api_get_schema_with_schema[mysql_pymysql_engine] __ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s ___ ERROR at teardown of test_api_get_schema_with_schema[mysql_pymysql_conn] ___ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_get_schema_with_schema[postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_get_schema_with_schema[postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s ____ ERROR at teardown of test_api_get_schema_dtypes[mysql_pymysql_engine] _____ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _____ ERROR at teardown of test_api_get_schema_dtypes[mysql_pymysql_conn] ______ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_get_schema_dtypes[postgresql_psycopg2_engine] __ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s __ ERROR at teardown of test_api_get_schema_dtypes[postgresql_psycopg2_conn] ___ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _____ ERROR at teardown of test_api_get_schema_keys[mysql_pymysql_engine] ______ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s ______ ERROR at teardown of test_api_get_schema_keys[mysql_pymysql_conn] _______ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s __ ERROR at teardown of test_api_get_schema_keys[postgresql_psycopg2_engine] ___ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s ___ ERROR at teardown of test_api_get_schema_keys[postgresql_psycopg2_conn] ____ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s ______ ERROR at teardown of test_api_chunksize_read[mysql_pymysql_engine] ______ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _______ ERROR at teardown of test_api_chunksize_read[mysql_pymysql_conn] _______ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s ___ ERROR at teardown of test_api_chunksize_read[postgresql_psycopg2_engine] ___ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s ____ ERROR at teardown of test_api_chunksize_read[postgresql_psycopg2_conn] ____ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _______ ERROR at teardown of test_api_categorical[mysql_pymysql_engine] ________ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s ________ ERROR at teardown of test_api_categorical[mysql_pymysql_conn] _________ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s ____ ERROR at teardown of test_api_categorical[postgresql_psycopg2_engine] _____ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _____ ERROR at teardown of test_api_categorical[postgresql_psycopg2_conn] ______ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s ___ ERROR at teardown of test_api_unicode_column_name[mysql_pymysql_engine] ____ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s ____ ERROR at teardown of test_api_unicode_column_name[mysql_pymysql_conn] _____ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_unicode_column_name[postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_unicode_column_name[postgresql_psycopg2_conn] __ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s ____ ERROR at teardown of test_api_escaped_table_name[mysql_pymysql_engine] ____ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _____ ERROR at teardown of test_api_escaped_table_name[mysql_pymysql_conn] _____ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_escaped_table_name[postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s __ ERROR at teardown of test_api_escaped_table_name[postgresql_psycopg2_conn] __ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_read_sql_duplicate_columns[mysql_pymysql_engine] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_read_sql_duplicate_columns[mysql_pymysql_conn] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_api_read_sql_duplicate_columns[postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_api_read_sql_duplicate_columns[postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s ______ ERROR at teardown of test_read_table_columns[mysql_pymysql_engine] ______ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _______ ERROR at teardown of test_read_table_columns[mysql_pymysql_conn] _______ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s ___ ERROR at teardown of test_read_table_columns[postgresql_psycopg2_engine] ___ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s ____ ERROR at teardown of test_read_table_columns[postgresql_psycopg2_conn] ____ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _____ ERROR at teardown of test_read_table_index_col[mysql_pymysql_engine] _____ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s ______ ERROR at teardown of test_read_table_index_col[mysql_pymysql_conn] ______ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s __ ERROR at teardown of test_read_table_index_col[postgresql_psycopg2_engine] __ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s ___ ERROR at teardown of test_read_table_index_col[postgresql_psycopg2_conn] ___ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s ____ ERROR at teardown of test_read_sql_delegate[mysql_pymysql_engine_iris] ____ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _____ ERROR at teardown of test_read_sql_delegate[mysql_pymysql_conn_iris] _____ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_read_sql_delegate[postgresql_psycopg2_engine_iris] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s __ ERROR at teardown of test_read_sql_delegate[postgresql_psycopg2_conn_iris] __ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_warning_case_insensitive_table_name[mysql_pymysql_engine] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_warning_case_insensitive_table_name[mysql_pymysql_conn] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_warning_case_insensitive_table_name[postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_warning_case_insensitive_table_name[postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s ___ ERROR at teardown of test_sqlalchemy_type_mapping[mysql_pymysql_engine] ____ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s ____ ERROR at teardown of test_sqlalchemy_type_mapping[mysql_pymysql_conn] _____ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_type_mapping[postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_type_mapping[postgresql_psycopg2_conn] __ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_engine] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_conn] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_engine] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_conn] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_engine] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_conn] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_engine] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_conn] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_engine] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_conn] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_engine] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_conn] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_engine] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_conn] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_engine] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_conn] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_engine] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_conn] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_engine] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_conn] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_engine] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_conn] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_engine] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_conn] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_engine] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_conn] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_engine] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_conn] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_engine] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_conn] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_engine] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_conn] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_engine] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_conn] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _____ ERROR at teardown of test_database_uri_string[mysql_pymysql_engine] ______ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s ______ ERROR at teardown of test_database_uri_string[mysql_pymysql_conn] _______ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s __ ERROR at teardown of test_database_uri_string[postgresql_psycopg2_engine] ___ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s ___ ERROR at teardown of test_database_uri_string[postgresql_psycopg2_conn] ____ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_engine] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_conn] _ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_conn] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s ____ ERROR at teardown of test_query_by_text_obj[mysql_pymysql_engine_iris] ____ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _____ ERROR at teardown of test_query_by_text_obj[mysql_pymysql_conn_iris] _____ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_query_by_text_obj[postgresql_psycopg2_engine_iris] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s __ ERROR at teardown of test_query_by_text_obj[postgresql_psycopg2_conn_iris] __ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s ___ ERROR at teardown of test_query_by_select_obj[mysql_pymysql_engine_iris] ___ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s ____ ERROR at teardown of test_query_by_select_obj[mysql_pymysql_conn_iris] ____ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_query_by_select_obj[postgresql_psycopg2_engine_iris] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _ ERROR at teardown of test_query_by_select_obj[postgresql_psycopg2_conn_iris] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s ____ ERROR at teardown of test_column_with_percentage[mysql_pymysql_engine] ____ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _____ ERROR at teardown of test_column_with_percentage[mysql_pymysql_conn] _____ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s _ ERROR at teardown of test_column_with_percentage[postgresql_psycopg2_engine] _ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s __ ERROR at teardown of test_column_with_percentage[postgresql_psycopg2_conn] __ 1428s self = 1428s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1428s connection = None, _has_events = None, _allow_revalidate = True 1428s _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def postgresql_psycopg2_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s td.versioned_importorskip("psycopg2") 1428s engine = sqlalchemy.create_engine( 1428s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1428s connection_factory = None, cursor_factory = None 1428s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1428s kwasync = {} 1428s 1428s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1428s """ 1428s Create a new database connection. 1428s 1428s The connection parameters can be specified as a string: 1428s 1428s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1428s 1428s or using a set of keyword arguments: 1428s 1428s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1428s 1428s Or as a mix of both. The basic connection parameters are: 1428s 1428s - *dbname*: the database name 1428s - *database*: the database name (only as keyword argument) 1428s - *user*: user name used to authenticate 1428s - *password*: password used to authenticate 1428s - *host*: database host address (defaults to UNIX socket if not provided) 1428s - *port*: connection port number (defaults to 5432 if not provided) 1428s 1428s Using the *connection_factory* parameter a different class or connections 1428s factory can be specified. It should be a callable object taking a dsn 1428s argument. 1428s 1428s Using the *cursor_factory* parameter, a new default cursor factory will be 1428s used by cursor(). 1428s 1428s Using *async*=True an asynchronous connection will be created. *async_* is 1428s a valid alias (for Python versions where ``async`` is a keyword). 1428s 1428s Any other keyword parameter will be passed to the underlying client 1428s library: the list of supported parameters depends on the library version. 1428s 1428s """ 1428s kwasync = {} 1428s if 'async' in kwargs: 1428s kwasync['async'] = kwargs.pop('async') 1428s if 'async_' in kwargs: 1428s kwasync['async_'] = kwargs.pop('async_') 1428s 1428s dsn = _ext.make_dsn(dsn, **kwargs) 1428s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1428s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1428s E Is the server running on that host and accepting TCP/IP connections? 1428s E 1428s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1428s 1428s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1428s _________ ERROR at teardown of test_create_table[mysql_pymysql_engine] _________ 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s > sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3.13/socket.py:864: in create_connection 1428s raise exceptions[0] 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s address = ('localhost', 3306), timeout = 10, source_address = None 1428s 1428s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1428s source_address=None, *, all_errors=False): 1428s """Connect to *address* and return the socket object. 1428s 1428s Convenience function. Connect to *address* (a 2-tuple ``(host, 1428s port)``) and return the socket object. Passing the optional 1428s *timeout* parameter will set the timeout on the socket instance 1428s before attempting to connect. If no *timeout* is supplied, the 1428s global default timeout setting returned by :func:`getdefaulttimeout` 1428s is used. If *source_address* is set it must be a tuple of (host, port) 1428s for the socket to bind as a source address before making the connection. 1428s A host of '' or port 0 tells the OS to use the default. When a connection 1428s cannot be created, raises the last error if *all_errors* is False, 1428s and an ExceptionGroup of all errors if *all_errors* is True. 1428s """ 1428s 1428s host, port = address 1428s exceptions = [] 1428s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1428s af, socktype, proto, canonname, sa = res 1428s sock = None 1428s try: 1428s sock = socket(af, socktype, proto) 1428s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1428s sock.settimeout(timeout) 1428s if source_address: 1428s sock.bind(source_address) 1428s > sock.connect(sa) 1428s E ConnectionRefusedError: [Errno 111] Connection refused 1428s 1428s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1428s 1428s During handling of the above exception, another exception occurred: 1428s 1428s self = 1428s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1428s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1428s 1428s def __init__( 1428s self, 1428s engine: Engine, 1428s connection: Optional[PoolProxiedConnection] = None, 1428s _has_events: Optional[bool] = None, 1428s _allow_revalidate: bool = True, 1428s _allow_autobegin: bool = True, 1428s ): 1428s """Construct a new Connection.""" 1428s self.engine = engine 1428s self.dialect = dialect = engine.dialect 1428s 1428s if connection is None: 1428s try: 1428s > self._dbapi_connection = engine.raw_connection() 1428s 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1428s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1428s sock.settimeout(self.connect_timeout) 1428s sock.connect(self.unix_socket) 1428s self.host_info = "Localhost via UNIX socket" 1428s self._secure = True 1428s if DEBUG: 1428s print("connected using unix_socket") 1428s else: 1428s kwargs = {} 1428s if self.bind_address is not None: 1428s kwargs["source_address"] = (self.bind_address, 0) 1428s while True: 1428s try: 1428s sock = socket.create_connection( 1428s (self.host, self.port), self.connect_timeout, **kwargs 1428s ) 1428s break 1428s except OSError as e: 1428s if e.errno == errno.EINTR: 1428s continue 1428s raise 1428s self.host_info = "socket %s:%d" % (self.host, self.port) 1428s if DEBUG: 1428s print("connected using socket") 1428s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1428s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1428s sock.settimeout(None) 1428s 1428s self._sock = sock 1428s self._rfile = sock.makefile("rb") 1428s self._next_seq_id = 0 1428s 1428s self._get_server_information() 1428s self._request_authentication() 1428s 1428s # Send "SET NAMES" query on init for: 1428s # - Ensure charaset (and collation) is set to the server. 1428s # - collation_id in handshake packet may be ignored. 1428s # - If collation is not specified, we don't know what is server's 1428s # default collation for the charset. For example, default collation 1428s # of utf8mb4 is: 1428s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1428s # - MySQL 8.0: utf8mb4_0900_ai_ci 1428s # 1428s # Reference: 1428s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1428s # - https://github.com/wagtail/wagtail/issues/9477 1428s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1428s self.set_character_set(self.charset, self.collation) 1428s 1428s if self.sql_mode is not None: 1428s c = self.cursor() 1428s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1428s c.close() 1428s 1428s if self.init_command is not None: 1428s c = self.cursor() 1428s c.execute(self.init_command) 1428s c.close() 1428s 1428s if self.autocommit_mode is not None: 1428s self.autocommit(self.autocommit_mode) 1428s except BaseException as e: 1428s self._rfile = None 1428s if sock is not None: 1428s try: 1428s sock.close() 1428s except: # noqa 1428s pass 1428s 1428s if isinstance(e, (OSError, IOError)): 1428s exc = err.OperationalError( 1428s CR.CR_CONN_HOST_ERROR, 1428s f"Can't connect to MySQL server on {self.host!r} ({e})", 1428s ) 1428s # Keep original exception and traceback to investigate error. 1428s exc.original_exception = e 1428s exc.traceback = traceback.format_exc() 1428s if DEBUG: 1428s print(exc.traceback) 1428s > raise exc 1428s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1428s 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1428s 1428s The above exception was the direct cause of the following exception: 1428s 1428s @pytest.fixture 1428s def mysql_pymysql_engine(): 1428s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1428s pymysql = td.versioned_importorskip("pymysql") 1428s engine = sqlalchemy.create_engine( 1428s "mysql+pymysql://root@localhost:3306/pandas", 1428s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1428s poolclass=sqlalchemy.pool.NullPool, 1428s ) 1428s yield engine 1428s > for view in get_all_views(engine): 1428s 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1428s return inspect(conn).get_view_names() 1428s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1428s ret = reg(subject) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1428s return Inspector._construct(Inspector._init_engine, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1428s init(self, bind) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1428s engine.connect().close() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1428s return self._connection_cls(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1428s Connection._handle_dbapi_exception_noconnection( 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1428s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1428s self._dbapi_connection = engine.raw_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1428s return self.pool.connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1428s return _ConnectionFairy._checkout(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1428s fairy = _ConnectionRecord.checkout(pool) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1428s rec = pool._do_get() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1428s return self._create_connection() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1428s return _ConnectionRecord(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1428s self.__connect() 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1428s with util.safe_reraise(): 1428s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1428s raise exc_value.with_traceback(exc_tb) 1428s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1428s self.dbapi_connection = connection = pool._invoke_creator(self) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1428s return dialect.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1428s return self.loaded_dbapi.connect(*cargs, **cparams) 1428s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1428s self.connect() 1428s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1428s 1428s self = , sock = None 1428s 1428s def connect(self, sock=None): 1428s self._closed = False 1428s try: 1428s if sock is None: 1428s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s __________ ERROR at teardown of test_create_table[mysql_pymysql_conn] __________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ______ ERROR at teardown of test_create_table[postgresql_psycopg2_engine] ______ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _______ ERROR at teardown of test_create_table[postgresql_psycopg2_conn] _______ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s __________ ERROR at teardown of test_drop_table[mysql_pymysql_engine] __________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ___________ ERROR at teardown of test_drop_table[mysql_pymysql_conn] ___________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _______ ERROR at teardown of test_drop_table[postgresql_psycopg2_engine] _______ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ________ ERROR at teardown of test_drop_table[postgresql_psycopg2_conn] ________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s __________ ERROR at teardown of test_roundtrip[mysql_pymysql_engine] ___________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ___________ ERROR at teardown of test_roundtrip[mysql_pymysql_conn] ____________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _______ ERROR at teardown of test_roundtrip[postgresql_psycopg2_engine] ________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ________ ERROR at teardown of test_roundtrip[postgresql_psycopg2_conn] _________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _______ ERROR at teardown of test_execute_sql[mysql_pymysql_engine_iris] _______ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ________ ERROR at teardown of test_execute_sql[mysql_pymysql_conn_iris] ________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ____ ERROR at teardown of test_execute_sql[postgresql_psycopg2_engine_iris] ____ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _____ ERROR at teardown of test_execute_sql[postgresql_psycopg2_conn_iris] _____ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s __ ERROR at teardown of test_sqlalchemy_read_table[mysql_pymysql_engine_iris] __ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ___ ERROR at teardown of test_sqlalchemy_read_table[mysql_pymysql_conn_iris] ___ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_sqlalchemy_read_table[postgresql_psycopg2_engine_iris] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_sqlalchemy_read_table[postgresql_psycopg2_conn_iris] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_sqlalchemy_read_table_columns[mysql_pymysql_engine_iris] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_sqlalchemy_read_table_columns[mysql_pymysql_conn_iris] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_sqlalchemy_read_table_columns[postgresql_psycopg2_engine_iris] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_sqlalchemy_read_table_columns[postgresql_psycopg2_conn_iris] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_read_table_absent_raises[mysql_pymysql_engine_iris] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_read_table_absent_raises[mysql_pymysql_conn_iris] __ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_read_table_absent_raises[postgresql_psycopg2_engine_iris] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_read_table_absent_raises[postgresql_psycopg2_conn_iris] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_sqlalchemy_default_type_conversion[postgresql_psycopg2_engine_types] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_sqlalchemy_default_type_conversion[postgresql_psycopg2_conn_types] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ____________ ERROR at teardown of test_bigint[mysql_pymysql_engine] ____________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _____________ ERROR at teardown of test_bigint[mysql_pymysql_conn] _____________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _________ ERROR at teardown of test_bigint[postgresql_psycopg2_engine] _________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s __________ ERROR at teardown of test_bigint[postgresql_psycopg2_conn] __________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ___ ERROR at teardown of test_default_date_load[mysql_pymysql_engine_types] ____ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ____ ERROR at teardown of test_default_date_load[mysql_pymysql_conn_types] _____ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_default_date_load[postgresql_psycopg2_engine_types] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_default_date_load[postgresql_psycopg2_conn_types] __ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_datetime_with_timezone_query[None-postgresql_psycopg2_engine] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_datetime_with_timezone_query[None-postgresql_psycopg2_conn] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_engine] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_conn] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_engine] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_conn] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_datetime_with_timezone_table[postgresql_psycopg2_engine] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_datetime_with_timezone_table[postgresql_psycopg2_conn] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_datetime_with_timezone_roundtrip[mysql_pymysql_engine] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_datetime_with_timezone_roundtrip[mysql_pymysql_conn] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_datetime_with_timezone_roundtrip[postgresql_psycopg2_engine] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_datetime_with_timezone_roundtrip[postgresql_psycopg2_conn] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ____ ERROR at teardown of test_out_of_bounds_datetime[mysql_pymysql_engine] ____ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _____ ERROR at teardown of test_out_of_bounds_datetime[mysql_pymysql_conn] _____ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_out_of_bounds_datetime[postgresql_psycopg2_engine] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s __ ERROR at teardown of test_out_of_bounds_datetime[postgresql_psycopg2_conn] __ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_naive_datetimeindex_roundtrip[mysql_pymysql_engine] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_naive_datetimeindex_roundtrip[mysql_pymysql_conn] __ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_naive_datetimeindex_roundtrip[postgresql_psycopg2_engine] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_naive_datetimeindex_roundtrip[postgresql_psycopg2_conn] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ______ ERROR at teardown of test_date_parsing[mysql_pymysql_engine_types] ______ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _______ ERROR at teardown of test_date_parsing[mysql_pymysql_conn_types] _______ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ___ ERROR at teardown of test_date_parsing[postgresql_psycopg2_engine_types] ___ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ____ ERROR at teardown of test_date_parsing[postgresql_psycopg2_conn_types] ____ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ___________ ERROR at teardown of test_datetime[mysql_pymysql_engine] ___________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ____________ ERROR at teardown of test_datetime[mysql_pymysql_conn] ____________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ________ ERROR at teardown of test_datetime[postgresql_psycopg2_engine] ________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _________ ERROR at teardown of test_datetime[postgresql_psycopg2_conn] _________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _________ ERROR at teardown of test_datetime_NaT[mysql_pymysql_engine] _________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s __________ ERROR at teardown of test_datetime_NaT[mysql_pymysql_conn] __________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ______ ERROR at teardown of test_datetime_NaT[postgresql_psycopg2_engine] ______ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _______ ERROR at teardown of test_datetime_NaT[postgresql_psycopg2_conn] _______ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ________ ERROR at teardown of test_datetime_date[mysql_pymysql_engine] _________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _________ ERROR at teardown of test_datetime_date[mysql_pymysql_conn] __________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _____ ERROR at teardown of test_datetime_date[postgresql_psycopg2_engine] ______ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ______ ERROR at teardown of test_datetime_date[postgresql_psycopg2_conn] _______ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ________ ERROR at teardown of test_datetime_time[mysql_pymysql_engine] _________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _________ ERROR at teardown of test_datetime_time[mysql_pymysql_conn] __________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _____ ERROR at teardown of test_datetime_time[postgresql_psycopg2_engine] ______ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ______ ERROR at teardown of test_datetime_time[postgresql_psycopg2_conn] _______ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ______ ERROR at teardown of test_mixed_dtype_insert[mysql_pymysql_engine] ______ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _______ ERROR at teardown of test_mixed_dtype_insert[mysql_pymysql_conn] _______ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ___ ERROR at teardown of test_mixed_dtype_insert[postgresql_psycopg2_engine] ___ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ____ ERROR at teardown of test_mixed_dtype_insert[postgresql_psycopg2_conn] ____ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _________ ERROR at teardown of test_nan_numeric[mysql_pymysql_engine] __________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s __________ ERROR at teardown of test_nan_numeric[mysql_pymysql_conn] ___________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ______ ERROR at teardown of test_nan_numeric[postgresql_psycopg2_engine] _______ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _______ ERROR at teardown of test_nan_numeric[postgresql_psycopg2_conn] ________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ________ ERROR at teardown of test_nan_fullcolumn[mysql_pymysql_engine] ________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _________ ERROR at teardown of test_nan_fullcolumn[mysql_pymysql_conn] _________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _____ ERROR at teardown of test_nan_fullcolumn[postgresql_psycopg2_engine] _____ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ______ ERROR at teardown of test_nan_fullcolumn[postgresql_psycopg2_conn] ______ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s __________ ERROR at teardown of test_nan_string[mysql_pymysql_engine] __________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ___________ ERROR at teardown of test_nan_string[mysql_pymysql_conn] ___________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _______ ERROR at teardown of test_nan_string[postgresql_psycopg2_engine] _______ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ________ ERROR at teardown of test_nan_string[postgresql_psycopg2_conn] ________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ______ ERROR at teardown of test_to_sql_save_index[mysql_pymysql_engine] _______ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _______ ERROR at teardown of test_to_sql_save_index[mysql_pymysql_conn] ________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ___ ERROR at teardown of test_to_sql_save_index[postgresql_psycopg2_engine] ____ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ____ ERROR at teardown of test_to_sql_save_index[postgresql_psycopg2_conn] _____ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _________ ERROR at teardown of test_transactions[mysql_pymysql_engine] _________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s __________ ERROR at teardown of test_transactions[mysql_pymysql_conn] __________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ______ ERROR at teardown of test_transactions[postgresql_psycopg2_engine] ______ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _______ ERROR at teardown of test_transactions[postgresql_psycopg2_conn] _______ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _____ ERROR at teardown of test_transaction_rollback[mysql_pymysql_engine] _____ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ______ ERROR at teardown of test_transaction_rollback[mysql_pymysql_conn] ______ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s __ ERROR at teardown of test_transaction_rollback[postgresql_psycopg2_engine] __ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ___ ERROR at teardown of test_transaction_rollback[postgresql_psycopg2_conn] ___ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ___ ERROR at teardown of test_get_schema_create_table[mysql_pymysql_engine] ____ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ____ ERROR at teardown of test_get_schema_create_table[mysql_pymysql_conn] _____ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_get_schema_create_table[postgresql_psycopg2_engine] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_get_schema_create_table[postgresql_psycopg2_conn] __ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ____________ ERROR at teardown of test_dtype[mysql_pymysql_engine] _____________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _____________ ERROR at teardown of test_dtype[mysql_pymysql_conn] ______________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _________ ERROR at teardown of test_dtype[postgresql_psycopg2_engine] __________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s __________ ERROR at teardown of test_dtype[postgresql_psycopg2_conn] ___________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _________ ERROR at teardown of test_notna_dtype[mysql_pymysql_engine] __________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s __________ ERROR at teardown of test_notna_dtype[mysql_pymysql_conn] ___________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ______ ERROR at teardown of test_notna_dtype[postgresql_psycopg2_engine] _______ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _______ ERROR at teardown of test_notna_dtype[postgresql_psycopg2_conn] ________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _______ ERROR at teardown of test_double_precision[mysql_pymysql_engine] _______ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ________ ERROR at teardown of test_double_precision[mysql_pymysql_conn] ________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ____ ERROR at teardown of test_double_precision[postgresql_psycopg2_engine] ____ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _____ ERROR at teardown of test_double_precision[postgresql_psycopg2_conn] _____ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s __ ERROR at teardown of test_connectable_issue_example[mysql_pymysql_engine] ___ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ___ ERROR at teardown of test_connectable_issue_example[mysql_pymysql_conn] ____ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_connectable_issue_example[postgresql_psycopg2_engine] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_connectable_issue_example[postgresql_psycopg2_conn] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_to_sql_with_negative_npinf[input0-mysql_pymysql_engine] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_to_sql_with_negative_npinf[input0-mysql_pymysql_conn] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_engine] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_conn] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_to_sql_with_negative_npinf[input1-mysql_pymysql_engine] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_to_sql_with_negative_npinf[input1-mysql_pymysql_conn] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_engine] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_conn] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_to_sql_with_negative_npinf[input2-mysql_pymysql_engine] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_to_sql_with_negative_npinf[input2-mysql_pymysql_conn] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_engine] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_conn] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _______ ERROR at teardown of test_temporary_table[mysql_pymysql_engine] ________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ________ ERROR at teardown of test_temporary_table[mysql_pymysql_conn] _________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ____ ERROR at teardown of test_temporary_table[postgresql_psycopg2_engine] _____ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _____ ERROR at teardown of test_temporary_table[postgresql_psycopg2_conn] ______ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ________ ERROR at teardown of test_invalid_engine[mysql_pymysql_engine] ________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _________ ERROR at teardown of test_invalid_engine[mysql_pymysql_conn] _________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _____ ERROR at teardown of test_invalid_engine[postgresql_psycopg2_engine] _____ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ______ ERROR at teardown of test_invalid_engine[postgresql_psycopg2_conn] ______ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ____ ERROR at teardown of test_to_sql_with_sql_engine[mysql_pymysql_engine] ____ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _____ ERROR at teardown of test_to_sql_with_sql_engine[mysql_pymysql_conn] _____ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_to_sql_with_sql_engine[postgresql_psycopg2_engine] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s __ ERROR at teardown of test_to_sql_with_sql_engine[postgresql_psycopg2_conn] __ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ______ ERROR at teardown of test_options_sqlalchemy[mysql_pymysql_engine] ______ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _______ ERROR at teardown of test_options_sqlalchemy[mysql_pymysql_conn] _______ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ___ ERROR at teardown of test_options_sqlalchemy[postgresql_psycopg2_engine] ___ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ____ ERROR at teardown of test_options_sqlalchemy[postgresql_psycopg2_conn] ____ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _________ ERROR at teardown of test_options_auto[mysql_pymysql_engine] _________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s __________ ERROR at teardown of test_options_auto[mysql_pymysql_conn] __________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ______ ERROR at teardown of test_options_auto[postgresql_psycopg2_engine] ______ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _______ ERROR at teardown of test_options_auto[postgresql_psycopg2_conn] _______ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_engine] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_conn] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_engine] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_conn] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_engine] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_conn] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_engine] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_conn] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_engine] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_conn] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_engine] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_conn] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_engine] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_conn] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_engine] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_conn] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_engine] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_conn] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_engine] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_conn] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_engine] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_conn] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_engine] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_conn] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ____ ERROR at teardown of test_chunksize_empty_dtypes[mysql_pymysql_engine] ____ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _____ ERROR at teardown of test_chunksize_empty_dtypes[mysql_pymysql_conn] _____ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_chunksize_empty_dtypes[postgresql_psycopg2_engine] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s __ ERROR at teardown of test_chunksize_empty_dtypes[postgresql_psycopg2_conn] __ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_engine] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_conn] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_engine] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_conn] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_engine] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_conn] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_engine] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_conn] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_engine] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_conn] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_engine] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_conn] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_engine] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_conn] _ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def mysql_pymysql_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s pymysql = td.versioned_importorskip("pymysql") 1429s engine = sqlalchemy.create_engine( 1429s "mysql+pymysql://root@localhost:3306/pandas", 1429s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_engine] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_conn] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ______________ ERROR at teardown of test_psycopg2_schema_support _______________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _______________ ERROR at teardown of test_self_join_date_columns _______________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s @pytest.fixture 1429s def postgresql_psycopg2_engine(): 1429s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1429s td.versioned_importorskip("psycopg2") 1429s engine = sqlalchemy.create_engine( 1429s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1429s poolclass=sqlalchemy.pool.NullPool, 1429s ) 1429s yield engine 1429s > for view in get_all_views(engine): 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1429s return inspect(conn).get_view_names() 1429s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1429s ret = reg(subject) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1429s return Inspector._construct(Inspector._init_engine, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1429s init(self, bind) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1429s engine.connect().close() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s =================================== FAILURES =================================== 1429s _________________ test_dataframe_to_sql[mysql_pymysql_engine] __________________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable) 1429s def test_dataframe_to_sql(conn, test_frame1, request): 1429s # GH 51086 if conn is sqlite_engine 1429s conn = request.getfixturevalue(conn) 1429s > test_frame1.to_sql(name="test", con=conn, if_exists="append", index=False) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:983: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1429s return func(*args, **kwargs) 1429s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1429s return sql.to_sql( 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1429s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1429s return SQLDatabase(con, schema, need_transaction) 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1429s con = self.exit_stack.enter_context(con.connect()) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s __________________ test_dataframe_to_sql[mysql_pymysql_conn] ___________________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_conn' 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable) 1429s def test_dataframe_to_sql(conn, test_frame1, request): 1429s # GH 51086 if conn is sqlite_engine 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:982: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1429s with mysql_pymysql_engine.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ______________ test_dataframe_to_sql[postgresql_psycopg2_engine] _______________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable) 1429s def test_dataframe_to_sql(conn, test_frame1, request): 1429s # GH 51086 if conn is sqlite_engine 1429s conn = request.getfixturevalue(conn) 1429s > test_frame1.to_sql(name="test", con=conn, if_exists="append", index=False) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:983: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1429s return func(*args, **kwargs) 1429s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1429s return sql.to_sql( 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1429s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1429s return SQLDatabase(con, schema, need_transaction) 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1429s con = self.exit_stack.enter_context(con.connect()) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _______________ test_dataframe_to_sql[postgresql_psycopg2_conn] ________________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_conn' 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable) 1429s def test_dataframe_to_sql(conn, test_frame1, request): 1429s # GH 51086 if conn is sqlite_engine 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:982: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1429s with postgresql_psycopg2_engine.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ______________ test_dataframe_to_sql_empty[mysql_pymysql_engine] _______________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable) 1429s def test_dataframe_to_sql_empty(conn, test_frame1, request): 1429s if conn == "postgresql_adbc_conn": 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="postgres ADBC driver cannot insert index with null type", 1429s strict=True, 1429s ) 1429s ) 1429s # GH 51086 if conn is sqlite_engine 1429s conn = request.getfixturevalue(conn) 1429s empty_df = test_frame1.iloc[:0] 1429s > empty_df.to_sql(name="test", con=conn, if_exists="append", index=False) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:998: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1429s return func(*args, **kwargs) 1429s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1429s return sql.to_sql( 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1429s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1429s return SQLDatabase(con, schema, need_transaction) 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1429s con = self.exit_stack.enter_context(con.connect()) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _______________ test_dataframe_to_sql_empty[mysql_pymysql_conn] ________________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_conn' 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable) 1429s def test_dataframe_to_sql_empty(conn, test_frame1, request): 1429s if conn == "postgresql_adbc_conn": 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="postgres ADBC driver cannot insert index with null type", 1429s strict=True, 1429s ) 1429s ) 1429s # GH 51086 if conn is sqlite_engine 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:996: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1429s with mysql_pymysql_engine.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ___________ test_dataframe_to_sql_empty[postgresql_psycopg2_engine] ____________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable) 1429s def test_dataframe_to_sql_empty(conn, test_frame1, request): 1429s if conn == "postgresql_adbc_conn": 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="postgres ADBC driver cannot insert index with null type", 1429s strict=True, 1429s ) 1429s ) 1429s # GH 51086 if conn is sqlite_engine 1429s conn = request.getfixturevalue(conn) 1429s empty_df = test_frame1.iloc[:0] 1429s > empty_df.to_sql(name="test", con=conn, if_exists="append", index=False) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:998: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1429s return func(*args, **kwargs) 1429s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1429s return sql.to_sql( 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1429s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1429s return SQLDatabase(con, schema, need_transaction) 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1429s con = self.exit_stack.enter_context(con.connect()) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ____________ test_dataframe_to_sql_empty[postgresql_psycopg2_conn] _____________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_conn' 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable) 1429s def test_dataframe_to_sql_empty(conn, test_frame1, request): 1429s if conn == "postgresql_adbc_conn": 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="postgres ADBC driver cannot insert index with null type", 1429s strict=True, 1429s ) 1429s ) 1429s # GH 51086 if conn is sqlite_engine 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:996: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1429s with postgresql_psycopg2_engine.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ____________________ test_to_sql[None-mysql_pymysql_engine] ____________________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = Engine(mysql+pymysql://root@localhost:3306/pandas), method = None 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable) 1429s @pytest.mark.parametrize("method", [None, "multi"]) 1429s def test_to_sql(conn, method, test_frame1, request): 1429s if method == "multi" and "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="'method' not implemented for ADBC drivers", strict=True 1429s ) 1429s ) 1429s 1429s conn = request.getfixturevalue(conn) 1429s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1061: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1429s return SQLDatabase(con, schema, need_transaction) 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1429s con = self.exit_stack.enter_context(con.connect()) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _____________________ test_to_sql[None-mysql_pymysql_conn] _____________________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_conn', method = None 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable) 1429s @pytest.mark.parametrize("method", [None, "multi"]) 1429s def test_to_sql(conn, method, test_frame1, request): 1429s if method == "multi" and "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="'method' not implemented for ADBC drivers", strict=True 1429s ) 1429s ) 1429s 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1060: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1429s with mysql_pymysql_engine.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _________________ test_to_sql[None-postgresql_psycopg2_engine] _________________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s method = None 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable) 1429s @pytest.mark.parametrize("method", [None, "multi"]) 1429s def test_to_sql(conn, method, test_frame1, request): 1429s if method == "multi" and "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="'method' not implemented for ADBC drivers", strict=True 1429s ) 1429s ) 1429s 1429s conn = request.getfixturevalue(conn) 1429s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1061: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1429s return SQLDatabase(con, schema, need_transaction) 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1429s con = self.exit_stack.enter_context(con.connect()) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s __________________ test_to_sql[None-postgresql_psycopg2_conn] __________________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_conn', method = None 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable) 1429s @pytest.mark.parametrize("method", [None, "multi"]) 1429s def test_to_sql(conn, method, test_frame1, request): 1429s if method == "multi" and "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="'method' not implemented for ADBC drivers", strict=True 1429s ) 1429s ) 1429s 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1060: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1429s with postgresql_psycopg2_engine.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ___________________ test_to_sql[multi-mysql_pymysql_engine] ____________________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = Engine(mysql+pymysql://root@localhost:3306/pandas), method = 'multi' 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable) 1429s @pytest.mark.parametrize("method", [None, "multi"]) 1429s def test_to_sql(conn, method, test_frame1, request): 1429s if method == "multi" and "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="'method' not implemented for ADBC drivers", strict=True 1429s ) 1429s ) 1429s 1429s conn = request.getfixturevalue(conn) 1429s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1061: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1429s return SQLDatabase(con, schema, need_transaction) 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1429s con = self.exit_stack.enter_context(con.connect()) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ____________________ test_to_sql[multi-mysql_pymysql_conn] _____________________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_conn', method = 'multi' 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable) 1429s @pytest.mark.parametrize("method", [None, "multi"]) 1429s def test_to_sql(conn, method, test_frame1, request): 1429s if method == "multi" and "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="'method' not implemented for ADBC drivers", strict=True 1429s ) 1429s ) 1429s 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1060: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1429s with mysql_pymysql_engine.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ________________ test_to_sql[multi-postgresql_psycopg2_engine] _________________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s method = 'multi' 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable) 1429s @pytest.mark.parametrize("method", [None, "multi"]) 1429s def test_to_sql(conn, method, test_frame1, request): 1429s if method == "multi" and "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="'method' not implemented for ADBC drivers", strict=True 1429s ) 1429s ) 1429s 1429s conn = request.getfixturevalue(conn) 1429s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1061: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1429s return SQLDatabase(con, schema, need_transaction) 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1429s con = self.exit_stack.enter_context(con.connect()) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _________________ test_to_sql[multi-postgresql_psycopg2_conn] __________________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_conn', method = 'multi' 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable) 1429s @pytest.mark.parametrize("method", [None, "multi"]) 1429s def test_to_sql(conn, method, test_frame1, request): 1429s if method == "multi" and "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="'method' not implemented for ADBC drivers", strict=True 1429s ) 1429s ) 1429s 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1060: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1429s with postgresql_psycopg2_engine.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ______________ test_to_sql_exist[replace-1-mysql_pymysql_engine] _______________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = Engine(mysql+pymysql://root@localhost:3306/pandas), mode = 'replace' 1429s num_row_coef = 1 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable) 1429s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 1429s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 1429s conn = request.getfixturevalue(conn) 1429s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1071: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1429s return SQLDatabase(con, schema, need_transaction) 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1429s con = self.exit_stack.enter_context(con.connect()) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _______________ test_to_sql_exist[replace-1-mysql_pymysql_conn] ________________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_conn', mode = 'replace', num_row_coef = 1 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable) 1429s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 1429s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1070: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1429s with mysql_pymysql_engine.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ___________ test_to_sql_exist[replace-1-postgresql_psycopg2_engine] ____________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s mode = 'replace', num_row_coef = 1 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable) 1429s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 1429s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 1429s conn = request.getfixturevalue(conn) 1429s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1071: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1429s return SQLDatabase(con, schema, need_transaction) 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1429s con = self.exit_stack.enter_context(con.connect()) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ____________ test_to_sql_exist[replace-1-postgresql_psycopg2_conn] _____________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_conn', mode = 'replace', num_row_coef = 1 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable) 1429s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 1429s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1070: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1429s with postgresql_psycopg2_engine.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _______________ test_to_sql_exist[append-2-mysql_pymysql_engine] _______________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = Engine(mysql+pymysql://root@localhost:3306/pandas), mode = 'append' 1429s num_row_coef = 2 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable) 1429s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 1429s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 1429s conn = request.getfixturevalue(conn) 1429s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1071: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1429s return SQLDatabase(con, schema, need_transaction) 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1429s con = self.exit_stack.enter_context(con.connect()) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ________________ test_to_sql_exist[append-2-mysql_pymysql_conn] ________________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_conn', mode = 'append', num_row_coef = 2 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable) 1429s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 1429s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1070: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1429s with mysql_pymysql_engine.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ____________ test_to_sql_exist[append-2-postgresql_psycopg2_engine] ____________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s mode = 'append', num_row_coef = 2 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable) 1429s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 1429s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 1429s conn = request.getfixturevalue(conn) 1429s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1071: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1429s return SQLDatabase(con, schema, need_transaction) 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1429s con = self.exit_stack.enter_context(con.connect()) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _____________ test_to_sql_exist[append-2-postgresql_psycopg2_conn] _____________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_conn', mode = 'append', num_row_coef = 2 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable) 1429s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 1429s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1070: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1429s with postgresql_psycopg2_engine.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _________________ test_to_sql_exist_fail[mysql_pymysql_engine] _________________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable) 1429s def test_to_sql_exist_fail(conn, test_frame1, request): 1429s conn = request.getfixturevalue(conn) 1429s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1081: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1429s return SQLDatabase(con, schema, need_transaction) 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1429s con = self.exit_stack.enter_context(con.connect()) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s __________________ test_to_sql_exist_fail[mysql_pymysql_conn] __________________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_conn' 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable) 1429s def test_to_sql_exist_fail(conn, test_frame1, request): 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1080: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1429s with mysql_pymysql_engine.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ______________ test_to_sql_exist_fail[postgresql_psycopg2_engine] ______________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable) 1429s def test_to_sql_exist_fail(conn, test_frame1, request): 1429s conn = request.getfixturevalue(conn) 1429s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1081: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1429s return SQLDatabase(con, schema, need_transaction) 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1429s con = self.exit_stack.enter_context(con.connect()) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _______________ test_to_sql_exist_fail[postgresql_psycopg2_conn] _______________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_conn' 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable) 1429s def test_to_sql_exist_fail(conn, test_frame1, request): 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1080: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1429s with postgresql_psycopg2_engine.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _______________ test_read_iris_query[mysql_pymysql_engine_iris] ________________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_engine_iris' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_iris) 1429s def test_read_iris_query(conn, request): 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1092: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1429s create_and_load_iris(mysql_pymysql_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ________________ test_read_iris_query[mysql_pymysql_conn_iris] _________________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_conn_iris' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_iris) 1429s def test_read_iris_query(conn, request): 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1092: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1429s fixturedef = request._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1429s create_and_load_iris(mysql_pymysql_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ____________ test_read_iris_query[postgresql_psycopg2_engine_iris] _____________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_engine_iris' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_iris) 1429s def test_read_iris_query(conn, request): 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1092: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1429s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _____________ test_read_iris_query[postgresql_psycopg2_conn_iris] ______________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_conn_iris' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_iris) 1429s def test_read_iris_query(conn, request): 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1092: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1429s fixturedef = request._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1429s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s __________ test_read_iris_query_chunksize[mysql_pymysql_engine_iris] ___________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_engine_iris' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_iris) 1429s def test_read_iris_query_chunksize(conn, request): 1429s if "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="'chunksize' not implemented for ADBC drivers", 1429s strict=True, 1429s ) 1429s ) 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1111: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1429s create_and_load_iris(mysql_pymysql_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ___________ test_read_iris_query_chunksize[mysql_pymysql_conn_iris] ____________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_conn_iris' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_iris) 1429s def test_read_iris_query_chunksize(conn, request): 1429s if "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="'chunksize' not implemented for ADBC drivers", 1429s strict=True, 1429s ) 1429s ) 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1111: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1429s fixturedef = request._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1429s create_and_load_iris(mysql_pymysql_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _______ test_read_iris_query_chunksize[postgresql_psycopg2_engine_iris] ________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_engine_iris' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_iris) 1429s def test_read_iris_query_chunksize(conn, request): 1429s if "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="'chunksize' not implemented for ADBC drivers", 1429s strict=True, 1429s ) 1429s ) 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1111: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1429s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ________ test_read_iris_query_chunksize[postgresql_psycopg2_conn_iris] _________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_conn_iris' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_iris) 1429s def test_read_iris_query_chunksize(conn, request): 1429s if "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="'chunksize' not implemented for ADBC drivers", 1429s strict=True, 1429s ) 1429s ) 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1111: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1429s fixturedef = request._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1429s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s __ test_read_iris_query_expression_with_parameter[mysql_pymysql_engine_iris] ___ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_engine_iris' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1429s def test_read_iris_query_expression_with_parameter(conn, request): 1429s if "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="'chunksize' not implemented for ADBC drivers", 1429s strict=True, 1429s ) 1429s ) 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1130: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1429s create_and_load_iris(mysql_pymysql_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ___ test_read_iris_query_expression_with_parameter[mysql_pymysql_conn_iris] ____ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_conn_iris' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1429s def test_read_iris_query_expression_with_parameter(conn, request): 1429s if "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="'chunksize' not implemented for ADBC drivers", 1429s strict=True, 1429s ) 1429s ) 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1130: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1429s fixturedef = request._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1429s create_and_load_iris(mysql_pymysql_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ test_read_iris_query_expression_with_parameter[postgresql_psycopg2_engine_iris] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_engine_iris' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1429s def test_read_iris_query_expression_with_parameter(conn, request): 1429s if "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="'chunksize' not implemented for ADBC drivers", 1429s strict=True, 1429s ) 1429s ) 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1130: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1429s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ test_read_iris_query_expression_with_parameter[postgresql_psycopg2_conn_iris] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_conn_iris' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1429s def test_read_iris_query_expression_with_parameter(conn, request): 1429s if "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="'chunksize' not implemented for ADBC drivers", 1429s strict=True, 1429s ) 1429s ) 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1130: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1429s fixturedef = request._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1429s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ____ test_read_iris_query_string_with_parameter[mysql_pymysql_engine_iris] _____ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_engine_iris' 1429s request = > 1429s 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=?'}} 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_iris) 1429s def test_read_iris_query_string_with_parameter(conn, request, sql_strings): 1429s if "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="'chunksize' not implemented for ADBC drivers", 1429s strict=True, 1429s ) 1429s ) 1429s 1429s for db, query in sql_strings["read_parameters"].items(): 1429s if db in conn: 1429s break 1429s else: 1429s raise KeyError(f"No part of {conn} found in sql_strings['read_parameters']") 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1164: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1429s create_and_load_iris(mysql_pymysql_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _____ test_read_iris_query_string_with_parameter[mysql_pymysql_conn_iris] ______ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_conn_iris' 1429s request = > 1429s 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=?'}} 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_iris) 1429s def test_read_iris_query_string_with_parameter(conn, request, sql_strings): 1429s if "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="'chunksize' not implemented for ADBC drivers", 1429s strict=True, 1429s ) 1429s ) 1429s 1429s for db, query in sql_strings["read_parameters"].items(): 1429s if db in conn: 1429s break 1429s else: 1429s raise KeyError(f"No part of {conn} found in sql_strings['read_parameters']") 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1164: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1429s fixturedef = request._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1429s create_and_load_iris(mysql_pymysql_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ test_read_iris_query_string_with_parameter[postgresql_psycopg2_engine_iris] __ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_engine_iris' 1429s request = > 1429s 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=?'}} 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_iris) 1429s def test_read_iris_query_string_with_parameter(conn, request, sql_strings): 1429s if "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="'chunksize' not implemented for ADBC drivers", 1429s strict=True, 1429s ) 1429s ) 1429s 1429s for db, query in sql_strings["read_parameters"].items(): 1429s if db in conn: 1429s break 1429s else: 1429s raise KeyError(f"No part of {conn} found in sql_strings['read_parameters']") 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1164: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1429s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s __ test_read_iris_query_string_with_parameter[postgresql_psycopg2_conn_iris] ___ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_conn_iris' 1429s request = > 1429s 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=?'}} 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_iris) 1429s def test_read_iris_query_string_with_parameter(conn, request, sql_strings): 1429s if "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="'chunksize' not implemented for ADBC drivers", 1429s strict=True, 1429s ) 1429s ) 1429s 1429s for db, query in sql_strings["read_parameters"].items(): 1429s if db in conn: 1429s break 1429s else: 1429s raise KeyError(f"No part of {conn} found in sql_strings['read_parameters']") 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1164: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1429s fixturedef = request._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1429s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _______________ test_read_iris_table[mysql_pymysql_engine_iris] ________________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_engine_iris' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1429s def test_read_iris_table(conn, request): 1429s # GH 51015 if conn = sqlite_iris_str 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1172: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1429s create_and_load_iris(mysql_pymysql_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ________________ test_read_iris_table[mysql_pymysql_conn_iris] _________________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_conn_iris' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1429s def test_read_iris_table(conn, request): 1429s # GH 51015 if conn = sqlite_iris_str 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1172: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1429s fixturedef = request._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1429s create_and_load_iris(mysql_pymysql_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ____________ test_read_iris_table[postgresql_psycopg2_engine_iris] _____________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_engine_iris' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1429s def test_read_iris_table(conn, request): 1429s # GH 51015 if conn = sqlite_iris_str 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1172: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1429s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _____________ test_read_iris_table[postgresql_psycopg2_conn_iris] ______________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_conn_iris' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1429s def test_read_iris_table(conn, request): 1429s # GH 51015 if conn = sqlite_iris_str 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1172: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1429s fixturedef = request._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1429s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s __________ test_read_iris_table_chunksize[mysql_pymysql_engine_iris] ___________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_engine_iris' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1429s def test_read_iris_table_chunksize(conn, request): 1429s if "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1429s ) 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1185: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1429s create_and_load_iris(mysql_pymysql_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ___________ test_read_iris_table_chunksize[mysql_pymysql_conn_iris] ____________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_conn_iris' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1429s def test_read_iris_table_chunksize(conn, request): 1429s if "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1429s ) 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1185: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1429s fixturedef = request._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1429s create_and_load_iris(mysql_pymysql_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _______ test_read_iris_table_chunksize[postgresql_psycopg2_engine_iris] ________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_engine_iris' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1429s def test_read_iris_table_chunksize(conn, request): 1429s if "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1429s ) 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1185: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1429s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ________ test_read_iris_table_chunksize[postgresql_psycopg2_conn_iris] _________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_conn_iris' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1429s def test_read_iris_table_chunksize(conn, request): 1429s if "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1429s ) 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1185: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1429s fixturedef = request._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1429s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s __________________ test_to_sql_callable[mysql_pymysql_engine] __________________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1429s def test_to_sql_callable(conn, test_frame1, request): 1429s conn = request.getfixturevalue(conn) 1429s 1429s check = [] # used to double check function below is really being used 1429s 1429s def sample(pd_table, conn, keys, data_iter): 1429s check.append(1) 1429s data = [dict(zip(keys, row)) for row in data_iter] 1429s conn.execute(pd_table.table.insert(), data) 1429s 1429s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1203: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1429s return SQLDatabase(con, schema, need_transaction) 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1429s con = self.exit_stack.enter_context(con.connect()) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ___________________ test_to_sql_callable[mysql_pymysql_conn] ___________________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_conn' 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1429s def test_to_sql_callable(conn, test_frame1, request): 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1194: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1429s with mysql_pymysql_engine.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _______________ test_to_sql_callable[postgresql_psycopg2_engine] _______________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1429s def test_to_sql_callable(conn, test_frame1, request): 1429s conn = request.getfixturevalue(conn) 1429s 1429s check = [] # used to double check function below is really being used 1429s 1429s def sample(pd_table, conn, keys, data_iter): 1429s check.append(1) 1429s data = [dict(zip(keys, row)) for row in data_iter] 1429s conn.execute(pd_table.table.insert(), data) 1429s 1429s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1203: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1429s return SQLDatabase(con, schema, need_transaction) 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1429s con = self.exit_stack.enter_context(con.connect()) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ________________ test_to_sql_callable[postgresql_psycopg2_conn] ________________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_conn' 1429s test_frame1 = index A B C D 1429s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1429s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1429s def test_to_sql_callable(conn, test_frame1, request): 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1194: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1429s with postgresql_psycopg2_engine.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ___________ test_default_type_conversion[mysql_pymysql_engine_types] ___________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_engine_types' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_types) 1429s def test_default_type_conversion(conn, request): 1429s conn_name = conn 1429s if conn_name == "sqlite_buildin_types": 1429s request.applymarker( 1429s pytest.mark.xfail( 1429s reason="sqlite_buildin connection does not implement read_sql_table" 1429s ) 1429s ) 1429s 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1220: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1429s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1429s with conn.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ____________ test_default_type_conversion[mysql_pymysql_conn_types] ____________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_conn_types' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_types) 1429s def test_default_type_conversion(conn, request): 1429s conn_name = conn 1429s if conn_name == "sqlite_buildin_types": 1429s request.applymarker( 1429s pytest.mark.xfail( 1429s reason="sqlite_buildin connection does not implement read_sql_table" 1429s ) 1429s ) 1429s 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1220: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1429s fixturedef = request._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1429s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1429s with conn.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ________ test_default_type_conversion[postgresql_psycopg2_engine_types] ________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_engine_types' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_types) 1429s def test_default_type_conversion(conn, request): 1429s conn_name = conn 1429s if conn_name == "sqlite_buildin_types": 1429s request.applymarker( 1429s pytest.mark.xfail( 1429s reason="sqlite_buildin connection does not implement read_sql_table" 1429s ) 1429s ) 1429s 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1220: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1429s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1429s with conn.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _________ test_default_type_conversion[postgresql_psycopg2_conn_types] _________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_conn_types' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_types) 1429s def test_default_type_conversion(conn, request): 1429s conn_name = conn 1429s if conn_name == "sqlite_buildin_types": 1429s request.applymarker( 1429s pytest.mark.xfail( 1429s reason="sqlite_buildin connection does not implement read_sql_table" 1429s ) 1429s ) 1429s 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1220: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1429s fixturedef = request._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1429s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1429s with conn.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s __________________ test_read_procedure[mysql_pymysql_engine] ___________________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", mysql_connectable) 1429s def test_read_procedure(conn, request): 1429s conn = request.getfixturevalue(conn) 1429s 1429s # GH 7324 1429s # Although it is more an api test, it is added to the 1429s # mysql tests as sqlite does not have stored procedures 1429s from sqlalchemy import text 1429s from sqlalchemy.engine import Engine 1429s 1429s df = DataFrame({"a": [1, 2, 3], "b": [0.1, 0.2, 0.3]}) 1429s > df.to_sql(name="test_frame", con=conn, index=False) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1253: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1429s return func(*args, **kwargs) 1429s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1429s return sql.to_sql( 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1429s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1429s return SQLDatabase(con, schema, need_transaction) 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1429s con = self.exit_stack.enter_context(con.connect()) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ___________________ test_read_procedure[mysql_pymysql_conn] ____________________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_conn' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", mysql_connectable) 1429s def test_read_procedure(conn, request): 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1244: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1429s with mysql_pymysql_engine.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ____ test_copy_from_callable_insertion_method[2-postgresql_psycopg2_engine] ____ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s expected_count = 2 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", postgresql_connectable) 1429s @pytest.mark.parametrize("expected_count", [2, "Success!"]) 1429s def test_copy_from_callable_insertion_method(conn, expected_count, request): 1429s # GH 8953 1429s # Example in io.rst found under _io.sql.method 1429s # not available in sqlite, mysql 1429s def psql_insert_copy(table, conn, keys, data_iter): 1429s # gets a DBAPI connection that can provide a cursor 1429s dbapi_conn = conn.connection 1429s with dbapi_conn.cursor() as cur: 1429s s_buf = StringIO() 1429s writer = csv.writer(s_buf) 1429s writer.writerows(data_iter) 1429s s_buf.seek(0) 1429s 1429s columns = ", ".join([f'"{k}"' for k in keys]) 1429s if table.schema: 1429s table_name = f"{table.schema}.{table.name}" 1429s else: 1429s table_name = table.name 1429s 1429s sql_query = f"COPY {table_name} ({columns}) FROM STDIN WITH CSV" 1429s cur.copy_expert(sql=sql_query, file=s_buf) 1429s return expected_count 1429s 1429s conn = request.getfixturevalue(conn) 1429s expected = DataFrame({"col1": [1, 2], "col2": [0.1, 0.2], "col3": ["a", "n"]}) 1429s > result_count = expected.to_sql( 1429s name="test_frame", con=conn, index=False, method=psql_insert_copy 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1306: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1429s return func(*args, **kwargs) 1429s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1429s return sql.to_sql( 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1429s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1429s return SQLDatabase(con, schema, need_transaction) 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1429s con = self.exit_stack.enter_context(con.connect()) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _____ test_copy_from_callable_insertion_method[2-postgresql_psycopg2_conn] _____ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_conn', expected_count = 2 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", postgresql_connectable) 1429s @pytest.mark.parametrize("expected_count", [2, "Success!"]) 1429s def test_copy_from_callable_insertion_method(conn, expected_count, request): 1429s # GH 8953 1429s # Example in io.rst found under _io.sql.method 1429s # not available in sqlite, mysql 1429s def psql_insert_copy(table, conn, keys, data_iter): 1429s # gets a DBAPI connection that can provide a cursor 1429s dbapi_conn = conn.connection 1429s with dbapi_conn.cursor() as cur: 1429s s_buf = StringIO() 1429s writer = csv.writer(s_buf) 1429s writer.writerows(data_iter) 1429s s_buf.seek(0) 1429s 1429s columns = ", ".join([f'"{k}"' for k in keys]) 1429s if table.schema: 1429s table_name = f"{table.schema}.{table.name}" 1429s else: 1429s table_name = table.name 1429s 1429s sql_query = f"COPY {table_name} ({columns}) FROM STDIN WITH CSV" 1429s cur.copy_expert(sql=sql_query, file=s_buf) 1429s return expected_count 1429s 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1304: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1429s with postgresql_psycopg2_engine.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_engine] _ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s expected_count = 'Success!' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", postgresql_connectable) 1429s @pytest.mark.parametrize("expected_count", [2, "Success!"]) 1429s def test_copy_from_callable_insertion_method(conn, expected_count, request): 1429s # GH 8953 1429s # Example in io.rst found under _io.sql.method 1429s # not available in sqlite, mysql 1429s def psql_insert_copy(table, conn, keys, data_iter): 1429s # gets a DBAPI connection that can provide a cursor 1429s dbapi_conn = conn.connection 1429s with dbapi_conn.cursor() as cur: 1429s s_buf = StringIO() 1429s writer = csv.writer(s_buf) 1429s writer.writerows(data_iter) 1429s s_buf.seek(0) 1429s 1429s columns = ", ".join([f'"{k}"' for k in keys]) 1429s if table.schema: 1429s table_name = f"{table.schema}.{table.name}" 1429s else: 1429s table_name = table.name 1429s 1429s sql_query = f"COPY {table_name} ({columns}) FROM STDIN WITH CSV" 1429s cur.copy_expert(sql=sql_query, file=s_buf) 1429s return expected_count 1429s 1429s conn = request.getfixturevalue(conn) 1429s expected = DataFrame({"col1": [1, 2], "col2": [0.1, 0.2], "col3": ["a", "n"]}) 1429s > result_count = expected.to_sql( 1429s name="test_frame", con=conn, index=False, method=psql_insert_copy 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1306: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1429s return func(*args, **kwargs) 1429s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1429s return sql.to_sql( 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1429s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1429s return SQLDatabase(con, schema, need_transaction) 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1429s con = self.exit_stack.enter_context(con.connect()) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _ test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_conn] __ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_conn', expected_count = 'Success!' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", postgresql_connectable) 1429s @pytest.mark.parametrize("expected_count", [2, "Success!"]) 1429s def test_copy_from_callable_insertion_method(conn, expected_count, request): 1429s # GH 8953 1429s # Example in io.rst found under _io.sql.method 1429s # not available in sqlite, mysql 1429s def psql_insert_copy(table, conn, keys, data_iter): 1429s # gets a DBAPI connection that can provide a cursor 1429s dbapi_conn = conn.connection 1429s with dbapi_conn.cursor() as cur: 1429s s_buf = StringIO() 1429s writer = csv.writer(s_buf) 1429s writer.writerows(data_iter) 1429s s_buf.seek(0) 1429s 1429s columns = ", ".join([f'"{k}"' for k in keys]) 1429s if table.schema: 1429s table_name = f"{table.schema}.{table.name}" 1429s else: 1429s table_name = table.name 1429s 1429s sql_query = f"COPY {table_name} ({columns}) FROM STDIN WITH CSV" 1429s cur.copy_expert(sql=sql_query, file=s_buf) 1429s return expected_count 1429s 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1304: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1429s with postgresql_psycopg2_engine.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ___ test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_engine] ___ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", postgresql_connectable) 1429s def test_insertion_method_on_conflict_do_nothing(conn, request): 1429s # GH 15988: Example in to_sql docstring 1429s conn = request.getfixturevalue(conn) 1429s 1429s from sqlalchemy.dialects.postgresql import insert 1429s from sqlalchemy.engine import Engine 1429s from sqlalchemy.sql import text 1429s 1429s def insert_on_conflict(table, conn, keys, data_iter): 1429s data = [dict(zip(keys, row)) for row in data_iter] 1429s stmt = ( 1429s insert(table.table) 1429s .values(data) 1429s .on_conflict_do_nothing(index_elements=["a"]) 1429s ) 1429s result = conn.execute(stmt) 1429s return result.rowcount 1429s 1429s create_sql = text( 1429s """ 1429s CREATE TABLE test_insert_conflict ( 1429s a integer PRIMARY KEY, 1429s b numeric, 1429s c text 1429s ); 1429s """ 1429s ) 1429s if isinstance(conn, Engine): 1429s > with conn.connect() as con: 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1347: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ____ test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_conn] ____ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_conn' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", postgresql_connectable) 1429s def test_insertion_method_on_conflict_do_nothing(conn, request): 1429s # GH 15988: Example in to_sql docstring 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1321: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1429s with postgresql_psycopg2_engine.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ___________ test_to_sql_on_public_schema[postgresql_psycopg2_engine] ___________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable) 1429s def test_to_sql_on_public_schema(conn, request): 1429s if "sqlite" in conn or "mysql" in conn: 1429s request.applymarker( 1429s pytest.mark.xfail( 1429s reason="test for public schema only specific to postgresql" 1429s ) 1429s ) 1429s 1429s conn = request.getfixturevalue(conn) 1429s 1429s test_data = DataFrame([[1, 2.1, "a"], [2, 3.1, "b"]], columns=list("abc")) 1429s > test_data.to_sql( 1429s name="test_public_schema", 1429s con=conn, 1429s if_exists="append", 1429s index=False, 1429s schema="public", 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1388: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1429s return func(*args, **kwargs) 1429s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1429s return sql.to_sql( 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1429s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1429s return SQLDatabase(con, schema, need_transaction) 1429s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1429s con = self.exit_stack.enter_context(con.connect()) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ____________ test_to_sql_on_public_schema[postgresql_psycopg2_conn] ____________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_conn' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable) 1429s def test_to_sql_on_public_schema(conn, request): 1429s if "sqlite" in conn or "mysql" in conn: 1429s request.applymarker( 1429s pytest.mark.xfail( 1429s reason="test for public schema only specific to postgresql" 1429s ) 1429s ) 1429s 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1385: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1429s with postgresql_psycopg2_engine.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ________ test_insertion_method_on_conflict_update[mysql_pymysql_engine] ________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", mysql_connectable) 1429s def test_insertion_method_on_conflict_update(conn, request): 1429s # GH 14553: Example in to_sql docstring 1429s conn = request.getfixturevalue(conn) 1429s 1429s from sqlalchemy.dialects.mysql import insert 1429s from sqlalchemy.engine import Engine 1429s from sqlalchemy.sql import text 1429s 1429s def insert_on_conflict(table, conn, keys, data_iter): 1429s data = [dict(zip(keys, row)) for row in data_iter] 1429s stmt = insert(table.table).values(data) 1429s stmt = stmt.on_duplicate_key_update(b=stmt.inserted.b, c=stmt.inserted.c) 1429s result = conn.execute(stmt) 1429s return result.rowcount 1429s 1429s create_sql = text( 1429s """ 1429s CREATE TABLE test_insert_conflict ( 1429s a INT PRIMARY KEY, 1429s b FLOAT, 1429s c VARCHAR(10) 1429s ); 1429s """ 1429s ) 1429s if isinstance(conn, Engine): 1429s > with conn.connect() as con: 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1426: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _________ test_insertion_method_on_conflict_update[mysql_pymysql_conn] _________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_conn' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", mysql_connectable) 1429s def test_insertion_method_on_conflict_update(conn, request): 1429s # GH 14553: Example in to_sql docstring 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1403: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1429s with mysql_pymysql_engine.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _____________ test_read_view_postgres[postgresql_psycopg2_engine] ______________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", postgresql_connectable) 1429s def test_read_view_postgres(conn, request): 1429s # GH 52969 1429s conn = request.getfixturevalue(conn) 1429s 1429s from sqlalchemy.engine import Engine 1429s from sqlalchemy.sql import text 1429s 1429s table_name = f"group_{uuid.uuid4().hex}" 1429s view_name = f"group_view_{uuid.uuid4().hex}" 1429s 1429s sql_stmt = text( 1429s f""" 1429s CREATE TABLE {table_name} ( 1429s group_id INTEGER, 1429s name TEXT 1429s ); 1429s INSERT INTO {table_name} VALUES 1429s (1, 'name'); 1429s CREATE VIEW {view_name} 1429s AS 1429s SELECT * FROM {table_name}; 1429s """ 1429s ) 1429s if isinstance(conn, Engine): 1429s > with conn.connect() as con: 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1478: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ______________ test_read_view_postgres[postgresql_psycopg2_conn] _______________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_conn' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", postgresql_connectable) 1429s def test_read_view_postgres(conn, request): 1429s # GH 52969 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1456: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1429s with postgresql_psycopg2_engine.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ___________ test_read_sql_iris_parameter[mysql_pymysql_engine_iris] ____________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_engine_iris' 1429s request = > 1429s 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=?'}} 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_iris) 1429s def test_read_sql_iris_parameter(conn, request, sql_strings): 1429s if "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="'params' not implemented for ADBC drivers", 1429s strict=True, 1429s ) 1429s ) 1429s conn_name = conn 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1555: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1429s create_and_load_iris(mysql_pymysql_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ____________ test_read_sql_iris_parameter[mysql_pymysql_conn_iris] _____________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_conn_iris' 1429s request = > 1429s 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=?'}} 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_iris) 1429s def test_read_sql_iris_parameter(conn, request, sql_strings): 1429s if "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="'params' not implemented for ADBC drivers", 1429s strict=True, 1429s ) 1429s ) 1429s conn_name = conn 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1555: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1429s fixturedef = request._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1429s create_and_load_iris(mysql_pymysql_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ________ test_read_sql_iris_parameter[postgresql_psycopg2_engine_iris] _________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_engine_iris' 1429s request = > 1429s 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=?'}} 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_iris) 1429s def test_read_sql_iris_parameter(conn, request, sql_strings): 1429s if "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="'params' not implemented for ADBC drivers", 1429s strict=True, 1429s ) 1429s ) 1429s conn_name = conn 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1555: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1429s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s _________ test_read_sql_iris_parameter[postgresql_psycopg2_conn_iris] __________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_conn_iris' 1429s request = > 1429s 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=?'}} 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_iris) 1429s def test_read_sql_iris_parameter(conn, request, sql_strings): 1429s if "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="'params' not implemented for ADBC drivers", 1429s strict=True, 1429s ) 1429s ) 1429s conn_name = conn 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1555: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1429s fixturedef = request._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1429s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ________ test_read_sql_iris_named_parameter[mysql_pymysql_engine_iris] _________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_engine_iris' 1429s request = > 1429s 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=?'}} 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_iris) 1429s def test_read_sql_iris_named_parameter(conn, request, sql_strings): 1429s if "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="'params' not implemented for ADBC drivers", 1429s strict=True, 1429s ) 1429s ) 1429s 1429s conn_name = conn 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1575: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1429s create_and_load_iris(mysql_pymysql_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _________ test_read_sql_iris_named_parameter[mysql_pymysql_conn_iris] __________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_conn_iris' 1429s request = > 1429s 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=?'}} 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_iris) 1429s def test_read_sql_iris_named_parameter(conn, request, sql_strings): 1429s if "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="'params' not implemented for ADBC drivers", 1429s strict=True, 1429s ) 1429s ) 1429s 1429s conn_name = conn 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1575: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1429s fixturedef = request._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1429s create_and_load_iris(mysql_pymysql_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _____ test_read_sql_iris_named_parameter[postgresql_psycopg2_engine_iris] ______ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_engine_iris' 1429s request = > 1429s 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=?'}} 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_iris) 1429s def test_read_sql_iris_named_parameter(conn, request, sql_strings): 1429s if "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="'params' not implemented for ADBC drivers", 1429s strict=True, 1429s ) 1429s ) 1429s 1429s conn_name = conn 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1575: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1429s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ______ test_read_sql_iris_named_parameter[postgresql_psycopg2_conn_iris] _______ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_conn_iris' 1429s request = > 1429s 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=?'}} 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_iris) 1429s def test_read_sql_iris_named_parameter(conn, request, sql_strings): 1429s if "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail( 1429s reason="'params' not implemented for ADBC drivers", 1429s strict=True, 1429s ) 1429s ) 1429s 1429s conn_name = conn 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1575: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1429s fixturedef = request._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1429s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ______________ test_api_read_sql_view[mysql_pymysql_engine_iris] _______________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_engine_iris' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_iris) 1429s def test_api_read_sql_view(conn, request): 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1605: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1429s create_and_load_iris(mysql_pymysql_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _______________ test_api_read_sql_view[mysql_pymysql_conn_iris] ________________ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_conn_iris' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_iris) 1429s def test_api_read_sql_view(conn, request): 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1605: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1429s fixturedef = request._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1429s create_and_load_iris(mysql_pymysql_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s ___________ test_api_read_sql_view[postgresql_psycopg2_engine_iris] ____________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_engine_iris' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_iris) 1429s def test_api_read_sql_view(conn, request): 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1605: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1429s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ____________ test_api_read_sql_view[postgresql_psycopg2_conn_iris] _____________ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_conn_iris' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_iris) 1429s def test_api_read_sql_view(conn, request): 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1605: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1429s fixturedef = request._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1429s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s ____ test_api_read_sql_with_chunksize_no_result[mysql_pymysql_engine_iris] _____ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_engine_iris' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_iris) 1429s def test_api_read_sql_with_chunksize_no_result(conn, request): 1429s if "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1429s ) 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1616: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1429s create_and_load_iris(mysql_pymysql_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _____ test_api_read_sql_with_chunksize_no_result[mysql_pymysql_conn_iris] ______ 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s > sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3.13/socket.py:864: in create_connection 1429s raise exceptions[0] 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s address = ('localhost', 3306), timeout = 10, source_address = None 1429s 1429s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1429s source_address=None, *, all_errors=False): 1429s """Connect to *address* and return the socket object. 1429s 1429s Convenience function. Connect to *address* (a 2-tuple ``(host, 1429s port)``) and return the socket object. Passing the optional 1429s *timeout* parameter will set the timeout on the socket instance 1429s before attempting to connect. If no *timeout* is supplied, the 1429s global default timeout setting returned by :func:`getdefaulttimeout` 1429s is used. If *source_address* is set it must be a tuple of (host, port) 1429s for the socket to bind as a source address before making the connection. 1429s A host of '' or port 0 tells the OS to use the default. When a connection 1429s cannot be created, raises the last error if *all_errors* is False, 1429s and an ExceptionGroup of all errors if *all_errors* is True. 1429s """ 1429s 1429s host, port = address 1429s exceptions = [] 1429s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1429s af, socktype, proto, canonname, sa = res 1429s sock = None 1429s try: 1429s sock = socket(af, socktype, proto) 1429s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1429s sock.settimeout(timeout) 1429s if source_address: 1429s sock.bind(source_address) 1429s > sock.connect(sa) 1429s E ConnectionRefusedError: [Errno 111] Connection refused 1429s 1429s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1429s 1429s During handling of the above exception, another exception occurred: 1429s 1429s self = 1429s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1429s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'mysql_pymysql_conn_iris' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_iris) 1429s def test_api_read_sql_with_chunksize_no_result(conn, request): 1429s if "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1429s ) 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1616: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1429s fixturedef = request._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1429s create_and_load_iris(mysql_pymysql_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1429s self.connect() 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s self = , sock = None 1429s 1429s def connect(self, sock=None): 1429s self._closed = False 1429s try: 1429s if sock is None: 1429s if self.unix_socket: 1429s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1429s sock.settimeout(self.connect_timeout) 1429s sock.connect(self.unix_socket) 1429s self.host_info = "Localhost via UNIX socket" 1429s self._secure = True 1429s if DEBUG: 1429s print("connected using unix_socket") 1429s else: 1429s kwargs = {} 1429s if self.bind_address is not None: 1429s kwargs["source_address"] = (self.bind_address, 0) 1429s while True: 1429s try: 1429s sock = socket.create_connection( 1429s (self.host, self.port), self.connect_timeout, **kwargs 1429s ) 1429s break 1429s except OSError as e: 1429s if e.errno == errno.EINTR: 1429s continue 1429s raise 1429s self.host_info = "socket %s:%d" % (self.host, self.port) 1429s if DEBUG: 1429s print("connected using socket") 1429s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1429s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1429s sock.settimeout(None) 1429s 1429s self._sock = sock 1429s self._rfile = sock.makefile("rb") 1429s self._next_seq_id = 0 1429s 1429s self._get_server_information() 1429s self._request_authentication() 1429s 1429s # Send "SET NAMES" query on init for: 1429s # - Ensure charaset (and collation) is set to the server. 1429s # - collation_id in handshake packet may be ignored. 1429s # - If collation is not specified, we don't know what is server's 1429s # default collation for the charset. For example, default collation 1429s # of utf8mb4 is: 1429s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1429s # - MySQL 8.0: utf8mb4_0900_ai_ci 1429s # 1429s # Reference: 1429s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1429s # - https://github.com/wagtail/wagtail/issues/9477 1429s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1429s self.set_character_set(self.charset, self.collation) 1429s 1429s if self.sql_mode is not None: 1429s c = self.cursor() 1429s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1429s c.close() 1429s 1429s if self.init_command is not None: 1429s c = self.cursor() 1429s c.execute(self.init_command) 1429s c.close() 1429s 1429s if self.autocommit_mode is not None: 1429s self.autocommit(self.autocommit_mode) 1429s except BaseException as e: 1429s self._rfile = None 1429s if sock is not None: 1429s try: 1429s sock.close() 1429s except: # noqa 1429s pass 1429s 1429s if isinstance(e, (OSError, IOError)): 1429s exc = err.OperationalError( 1429s CR.CR_CONN_HOST_ERROR, 1429s f"Can't connect to MySQL server on {self.host!r} ({e})", 1429s ) 1429s # Keep original exception and traceback to investigate error. 1429s exc.original_exception = e 1429s exc.traceback = traceback.format_exc() 1429s if DEBUG: 1429s print(exc.traceback) 1429s > raise exc 1429s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1429s _ test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_engine_iris] __ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_engine_iris' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_iris) 1429s def test_api_read_sql_with_chunksize_no_result(conn, request): 1429s if "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1429s ) 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1616: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1429s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E 1429s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s __ test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_conn_iris] ___ 1429s self = 1429s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1429s connection = None, _has_events = None, _allow_revalidate = True 1429s _allow_autobegin = True 1429s 1429s def __init__( 1429s self, 1429s engine: Engine, 1429s connection: Optional[PoolProxiedConnection] = None, 1429s _has_events: Optional[bool] = None, 1429s _allow_revalidate: bool = True, 1429s _allow_autobegin: bool = True, 1429s ): 1429s """Construct a new Connection.""" 1429s self.engine = engine 1429s self.dialect = dialect = engine.dialect 1429s 1429s if connection is None: 1429s try: 1429s > self._dbapi_connection = engine.raw_connection() 1429s 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1429s factory can be specified. It should be a callable object taking a dsn 1429s argument. 1429s 1429s Using the *cursor_factory* parameter, a new default cursor factory will be 1429s used by cursor(). 1429s 1429s Using *async*=True an asynchronous connection will be created. *async_* is 1429s a valid alias (for Python versions where ``async`` is a keyword). 1429s 1429s Any other keyword parameter will be passed to the underlying client 1429s library: the list of supported parameters depends on the library version. 1429s 1429s """ 1429s kwasync = {} 1429s if 'async' in kwargs: 1429s kwasync['async'] = kwargs.pop('async') 1429s if 'async_' in kwargs: 1429s kwasync['async_'] = kwargs.pop('async_') 1429s 1429s dsn = _ext.make_dsn(dsn, **kwargs) 1429s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1429s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1429s E Is the server running on that host and accepting TCP/IP connections? 1429s 1429s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1429s 1429s The above exception was the direct cause of the following exception: 1429s 1429s conn = 'postgresql_psycopg2_conn_iris' 1429s request = > 1429s 1429s @pytest.mark.parametrize("conn", all_connectable_iris) 1429s def test_api_read_sql_with_chunksize_no_result(conn, request): 1429s if "adbc" in conn: 1429s request.node.add_marker( 1429s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1429s ) 1429s > conn = request.getfixturevalue(conn) 1429s 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1616: 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1429s fixturedef = self._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1429s fixturedef = request._get_active_fixturedef(argname) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1429s fixturedef.execute(request=subrequest) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1429s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1429s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1429s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1429s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1429s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1429s return (yield) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1429s result = call_fixture_func(fixturefunc, request, kwargs) 1429s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1429s fixture_result = next(generator) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1429s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1429s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1429s with conn.begin() as con: 1429s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1429s return next(self.gen) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1429s with self.connect() as conn: 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1429s return self._connection_cls(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1429s Connection._handle_dbapi_exception_noconnection( 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1429s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1429s self._dbapi_connection = engine.raw_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1429s return self.pool.connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1429s return _ConnectionFairy._checkout(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1429s fairy = _ConnectionRecord.checkout(pool) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1429s rec = pool._do_get() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1429s return self._create_connection() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1429s return _ConnectionRecord(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1429s self.__connect() 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1429s with util.safe_reraise(): 1429s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1429s raise exc_value.with_traceback(exc_tb) 1429s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1429s self.dbapi_connection = connection = pool._invoke_creator(self) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1429s return dialect.connect(*cargs, **cparams) 1429s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1429s return self.loaded_dbapi.connect(*cargs, **cparams) 1429s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1429s 1429s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1429s connection_factory = None, cursor_factory = None 1429s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1429s kwasync = {} 1429s 1429s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1429s """ 1429s Create a new database connection. 1429s 1429s The connection parameters can be specified as a string: 1429s 1429s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1429s 1429s or using a set of keyword arguments: 1429s 1429s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1429s 1429s Or as a mix of both. The basic connection parameters are: 1429s 1429s - *dbname*: the database name 1429s - *database*: the database name (only as keyword argument) 1429s - *user*: user name used to authenticate 1429s - *password*: password used to authenticate 1429s - *host*: database host address (defaults to UNIX socket if not provided) 1429s - *port*: connection port number (defaults to 5432 if not provided) 1429s 1429s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ____________________ test_api_to_sql[mysql_pymysql_engine] _____________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_to_sql(conn, request, test_frame1): 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_frame1", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1626: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _____________________ test_api_to_sql[mysql_pymysql_conn] ______________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_to_sql(conn, request, test_frame1): 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1625: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _________________ test_api_to_sql[postgresql_psycopg2_engine] __________________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_to_sql(conn, request, test_frame1): 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_frame1", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1626: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s __________________ test_api_to_sql[postgresql_psycopg2_conn] ___________________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_to_sql(conn, request, test_frame1): 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1625: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s __________________ test_api_to_sql_fail[mysql_pymysql_engine] __________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_to_sql_fail(conn, request, test_frame1): 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_frame2", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1637: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ___________________ test_api_to_sql_fail[mysql_pymysql_conn] ___________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_to_sql_fail(conn, request, test_frame1): 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1636: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _______________ test_api_to_sql_fail[postgresql_psycopg2_engine] _______________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_to_sql_fail(conn, request, test_frame1): 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_frame2", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1637: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ________________ test_api_to_sql_fail[postgresql_psycopg2_conn] ________________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_to_sql_fail(conn, request, test_frame1): 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1636: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ________________ test_api_to_sql_replace[mysql_pymysql_engine] _________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_to_sql_replace(conn, request, test_frame1): 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_frame3", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1652: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _________________ test_api_to_sql_replace[mysql_pymysql_conn] __________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_to_sql_replace(conn, request, test_frame1): 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1651: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _____________ test_api_to_sql_replace[postgresql_psycopg2_engine] ______________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_to_sql_replace(conn, request, test_frame1): 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_frame3", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1652: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ______________ test_api_to_sql_replace[postgresql_psycopg2_conn] _______________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_to_sql_replace(conn, request, test_frame1): 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1651: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _________________ test_api_to_sql_append[mysql_pymysql_engine] _________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_to_sql_append(conn, request, test_frame1): 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_frame4", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1670: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s __________________ test_api_to_sql_append[mysql_pymysql_conn] __________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_to_sql_append(conn, request, test_frame1): 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1669: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ______________ test_api_to_sql_append[postgresql_psycopg2_engine] ______________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_to_sql_append(conn, request, test_frame1): 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_frame4", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1670: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _______________ test_api_to_sql_append[postgresql_psycopg2_conn] _______________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_to_sql_append(conn, request, test_frame1): 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1669: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ______________ test_api_to_sql_type_mapping[mysql_pymysql_engine] ______________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s test_frame3 = index A B 1430s 0 2000-01-03 00:00:00 2147483647 -1.987670 1430s 1 2000-01-04 00:00:00 -29 -0.041232 1430s 2 2000-01-05 00:00:00 20000 0.731168 1430s 3 2000-01-06 00:00:00 -290867 1.567621 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_to_sql_type_mapping(conn, request, test_frame3): 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_frame5", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1689: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _______________ test_api_to_sql_type_mapping[mysql_pymysql_conn] _______________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s test_frame3 = index A B 1430s 0 2000-01-03 00:00:00 2147483647 -1.987670 1430s 1 2000-01-04 00:00:00 -29 -0.041232 1430s 2 2000-01-05 00:00:00 20000 0.731168 1430s 3 2000-01-06 00:00:00 -290867 1.567621 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_to_sql_type_mapping(conn, request, test_frame3): 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1688: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ___________ test_api_to_sql_type_mapping[postgresql_psycopg2_engine] ___________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s test_frame3 = index A B 1430s 0 2000-01-03 00:00:00 2147483647 -1.987670 1430s 1 2000-01-04 00:00:00 -29 -0.041232 1430s 2 2000-01-05 00:00:00 20000 0.731168 1430s 3 2000-01-06 00:00:00 -290867 1.567621 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_to_sql_type_mapping(conn, request, test_frame3): 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_frame5", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1689: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ____________ test_api_to_sql_type_mapping[postgresql_psycopg2_conn] ____________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s test_frame3 = index A B 1430s 0 2000-01-03 00:00:00 2147483647 -1.987670 1430s 1 2000-01-04 00:00:00 -29 -0.041232 1430s 2 2000-01-05 00:00:00 20000 0.731168 1430s 3 2000-01-06 00:00:00 -290867 1.567621 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_to_sql_type_mapping(conn, request, test_frame3): 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1688: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _________________ test_api_to_sql_series[mysql_pymysql_engine] _________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_to_sql_series(conn, request): 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_series", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1702: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s __________________ test_api_to_sql_series[mysql_pymysql_conn] __________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_to_sql_series(conn, request): 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1701: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ______________ test_api_to_sql_series[postgresql_psycopg2_engine] ______________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_to_sql_series(conn, request): 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_series", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1702: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _______________ test_api_to_sql_series[postgresql_psycopg2_conn] _______________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_to_sql_series(conn, request): 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1701: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ___________________ test_api_roundtrip[mysql_pymysql_engine] ___________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_roundtrip(conn, request, test_frame1): 1430s conn_name = conn 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_frame_roundtrip", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1716: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ____________________ test_api_roundtrip[mysql_pymysql_conn] ____________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_roundtrip(conn, request, test_frame1): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1715: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ________________ test_api_roundtrip[postgresql_psycopg2_engine] ________________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_roundtrip(conn, request, test_frame1): 1430s conn_name = conn 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_frame_roundtrip", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1716: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _________________ test_api_roundtrip[postgresql_psycopg2_conn] _________________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_roundtrip(conn, request, test_frame1): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1715: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ______________ test_api_roundtrip_chunksize[mysql_pymysql_engine] ______________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_roundtrip_chunksize(conn, request, test_frame1): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1430s ) 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_frame_roundtrip", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1740: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _______________ test_api_roundtrip_chunksize[mysql_pymysql_conn] _______________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_roundtrip_chunksize(conn, request, test_frame1): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1430s ) 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1739: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ___________ test_api_roundtrip_chunksize[postgresql_psycopg2_engine] ___________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_roundtrip_chunksize(conn, request, test_frame1): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1430s ) 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_frame_roundtrip", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1740: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ____________ test_api_roundtrip_chunksize[postgresql_psycopg2_conn] ____________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_roundtrip_chunksize(conn, request, test_frame1): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1430s ) 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1739: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _______________ test_api_execute_sql[mysql_pymysql_engine_iris] ________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_engine_iris' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_iris) 1430s def test_api_execute_sql(conn, request): 1430s # drop_sql = "DROP TABLE IF EXISTS test" # should already be done 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1758: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1430s create_and_load_iris(mysql_pymysql_engine, iris_path) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1430s with conn.begin() as con: 1430s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1430s return next(self.gen) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1430s with self.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ________________ test_api_execute_sql[mysql_pymysql_conn_iris] _________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn_iris' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_iris) 1430s def test_api_execute_sql(conn, request): 1430s # drop_sql = "DROP TABLE IF EXISTS test" # should already be done 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1758: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1430s create_and_load_iris(mysql_pymysql_engine, iris_path) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1430s with conn.begin() as con: 1430s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1430s return next(self.gen) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1430s with self.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ____________ test_api_execute_sql[postgresql_psycopg2_engine_iris] _____________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_engine_iris' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_iris) 1430s def test_api_execute_sql(conn, request): 1430s # drop_sql = "DROP TABLE IF EXISTS test" # should already be done 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1758: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1430s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1430s with conn.begin() as con: 1430s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1430s return next(self.gen) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1430s with self.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _____________ test_api_execute_sql[postgresql_psycopg2_conn_iris] ______________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn_iris' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_iris) 1430s def test_api_execute_sql(conn, request): 1430s # drop_sql = "DROP TABLE IF EXISTS test" # should already be done 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1758: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1430s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1430s with conn.begin() as con: 1430s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1430s return next(self.gen) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1430s with self.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ______________ test_api_date_parsing[mysql_pymysql_engine_types] _______________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_engine_types' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s def test_api_date_parsing(conn, request): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1769: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1430s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _______________ test_api_date_parsing[mysql_pymysql_conn_types] ________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn_types' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s def test_api_date_parsing(conn, request): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1769: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1430s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ___________ test_api_date_parsing[postgresql_psycopg2_engine_types] ____________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_engine_types' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s def test_api_date_parsing(conn, request): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1769: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1430s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ____________ test_api_date_parsing[postgresql_psycopg2_conn_types] _____________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn_types' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s def test_api_date_parsing(conn, request): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1769: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1430s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_engine_types] _ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_engine_types' 1430s request = > 1430s read_sql = , text = 'SELECT * FROM types' 1430s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1430s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_conn_types] _ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn_types' 1430s request = > 1430s read_sql = , text = 'SELECT * FROM types' 1430s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1430s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_engine_types] _ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_engine_types' 1430s request = > 1430s read_sql = , text = 'SELECT * FROM types' 1430s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1430s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_conn_types] _ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn_types' 1430s request = > 1430s read_sql = , text = 'SELECT * FROM types' 1430s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1430s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_engine_types] _ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_engine_types' 1430s request = > 1430s read_sql = , text = 'SELECT * FROM types' 1430s mode = ('sqlalchemy', 'fallback'), error = 'raise' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1430s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_conn_types] _ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn_types' 1430s request = > 1430s read_sql = , text = 'SELECT * FROM types' 1430s mode = ('sqlalchemy', 'fallback'), error = 'raise' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1430s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_engine_types] _ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_engine_types' 1430s request = > 1430s read_sql = , text = 'SELECT * FROM types' 1430s mode = ('sqlalchemy', 'fallback'), error = 'raise' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1430s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_conn_types] _ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn_types' 1430s request = > 1430s read_sql = , text = 'SELECT * FROM types' 1430s mode = ('sqlalchemy', 'fallback'), error = 'raise' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1430s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_engine_types] _ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_engine_types' 1430s request = > 1430s read_sql = , text = 'SELECT * FROM types' 1430s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1430s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_conn_types] _ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn_types' 1430s request = > 1430s read_sql = , text = 'SELECT * FROM types' 1430s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1430s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_engine_types] _ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_engine_types' 1430s request = > 1430s read_sql = , text = 'SELECT * FROM types' 1430s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1430s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_conn_types] _ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn_types' 1430s request = > 1430s read_sql = , text = 'SELECT * FROM types' 1430s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1430s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_engine_types] _ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_engine_types' 1430s request = > 1430s read_sql = , text = 'types' 1430s mode = 'sqlalchemy', error = 'ignore' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1430s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_conn_types] _ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn_types' 1430s request = > 1430s read_sql = , text = 'types' 1430s mode = 'sqlalchemy', error = 'ignore' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1430s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] _ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_engine_types' 1430s request = > 1430s read_sql = , text = 'types' 1430s mode = 'sqlalchemy', error = 'ignore' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1430s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] _ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn_types' 1430s request = > 1430s read_sql = , text = 'types' 1430s mode = 'sqlalchemy', error = 'ignore' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1430s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_engine_types] _ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_engine_types' 1430s request = > 1430s read_sql = , text = 'types' 1430s mode = 'sqlalchemy', error = 'raise' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1430s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_conn_types] _ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn_types' 1430s request = > 1430s read_sql = , text = 'types' 1430s mode = 'sqlalchemy', error = 'raise' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1430s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] _ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_engine_types' 1430s request = > 1430s read_sql = , text = 'types' 1430s mode = 'sqlalchemy', error = 'raise' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1430s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] _ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn_types' 1430s request = > 1430s read_sql = , text = 'types' 1430s mode = 'sqlalchemy', error = 'raise' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1430s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_engine_types] _ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_engine_types' 1430s request = > 1430s read_sql = , text = 'types' 1430s mode = 'sqlalchemy', error = 'coerce' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1430s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_conn_types] _ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn_types' 1430s request = > 1430s read_sql = , text = 'types' 1430s mode = 'sqlalchemy', error = 'coerce' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1430s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] _ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_engine_types' 1430s request = > 1430s read_sql = , text = 'types' 1430s mode = 'sqlalchemy', error = 'coerce' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1430s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] _ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn_types' 1430s request = > 1430s read_sql = , text = 'types' 1430s mode = 'sqlalchemy', error = 'coerce' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1430s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_engine_types] _ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_engine_types' 1430s request = > 1430s read_sql = 1430s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 1430s error = 'ignore' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1430s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_conn_types] _ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn_types' 1430s request = > 1430s read_sql = 1430s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 1430s error = 'ignore' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1430s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_engine_types] _ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_engine_types' 1430s request = > 1430s read_sql = 1430s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 1430s error = 'ignore' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1430s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_conn_types] _ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn_types' 1430s request = > 1430s read_sql = 1430s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 1430s error = 'ignore' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1430s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_engine_types] _ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_engine_types' 1430s request = > 1430s read_sql = 1430s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback'), error = 'raise' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1430s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_conn_types] _ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn_types' 1430s request = > 1430s read_sql = 1430s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback'), error = 'raise' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1430s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_engine_types] _ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_engine_types' 1430s request = > 1430s read_sql = 1430s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback'), error = 'raise' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1430s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_conn_types] _ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn_types' 1430s request = > 1430s read_sql = 1430s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback'), error = 'raise' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1430s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_engine_types] _ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_engine_types' 1430s request = > 1430s read_sql = 1430s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 1430s error = 'coerce' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1430s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_conn_types] _ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn_types' 1430s request = > 1430s read_sql = 1430s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 1430s error = 'coerce' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1430s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_engine_types] _ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_engine_types' 1430s request = > 1430s read_sql = 1430s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 1430s error = 'coerce' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1430s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_conn_types] _ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn_types' 1430s request = > 1430s read_sql = 1430s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 1430s error = 'coerce' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1430s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_engine_types] _ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_engine_types' 1430s request = > 1430s read_sql = , text = 'types' 1430s mode = 'sqlalchemy', error = 'ignore' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1430s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_conn_types] _ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn_types' 1430s request = > 1430s read_sql = , text = 'types' 1430s mode = 'sqlalchemy', error = 'ignore' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1430s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] _ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_engine_types' 1430s request = > 1430s read_sql = , text = 'types' 1430s mode = 'sqlalchemy', error = 'ignore' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1430s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] _ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn_types' 1430s request = > 1430s read_sql = , text = 'types' 1430s mode = 'sqlalchemy', error = 'ignore' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1430s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_engine_types] _ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_engine_types' 1430s request = > 1430s read_sql = , text = 'types' 1430s mode = 'sqlalchemy', error = 'raise' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1430s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_conn_types] _ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn_types' 1430s request = > 1430s read_sql = , text = 'types' 1430s mode = 'sqlalchemy', error = 'raise' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1430s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] _ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_engine_types' 1430s request = > 1430s read_sql = , text = 'types' 1430s mode = 'sqlalchemy', error = 'raise' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1430s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] _ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn_types' 1430s request = > 1430s read_sql = , text = 'types' 1430s mode = 'sqlalchemy', error = 'raise' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1430s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_engine_types] _ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_engine_types' 1430s request = > 1430s read_sql = , text = 'types' 1430s mode = 'sqlalchemy', error = 'coerce' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1430s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_conn_types] _ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn_types' 1430s request = > 1430s read_sql = , text = 'types' 1430s mode = 'sqlalchemy', error = 'coerce' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1430s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] _ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_engine_types' 1430s request = > 1430s read_sql = , text = 'types' 1430s mode = 'sqlalchemy', error = 'coerce' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1430s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] _ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn_types' 1430s request = > 1430s read_sql = , text = 'types' 1430s mode = 'sqlalchemy', error = 'coerce' 1430s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1430s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1430s 1 first 2000-01-04 00:00:00 ... NaN NaN 1430s 1430s [2 rows x 9 columns] 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1430s @pytest.mark.parametrize( 1430s "read_sql, text, mode", 1430s [ 1430s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1430s (sql.read_sql, "types", ("sqlalchemy")), 1430s ( 1430s sql.read_sql_query, 1430s "SELECT * FROM types", 1430s ("sqlalchemy", "fallback"), 1430s ), 1430s (sql.read_sql_table, "types", ("sqlalchemy")), 1430s ], 1430s ) 1430s def test_api_custom_dateparsing_error( 1430s conn, request, read_sql, text, mode, error, types_data_frame 1430s ): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1430s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _____________ test_api_date_and_index[mysql_pymysql_engine_types] ______________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_engine_types' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s def test_api_date_and_index(conn, request): 1430s # Test case where same column appears in parse_date and index_col 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1880: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1430s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ______________ test_api_date_and_index[mysql_pymysql_conn_types] _______________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn_types' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s def test_api_date_and_index(conn, request): 1430s # Test case where same column appears in parse_date and index_col 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1880: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1430s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s __________ test_api_date_and_index[postgresql_psycopg2_engine_types] ___________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_engine_types' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s def test_api_date_and_index(conn, request): 1430s # Test case where same column appears in parse_date and index_col 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1880: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1430s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ___________ test_api_date_and_index[postgresql_psycopg2_conn_types] ____________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn_types' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_types) 1430s def test_api_date_and_index(conn, request): 1430s # Test case where same column appears in parse_date and index_col 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1880: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1430s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1430s with conn.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ___________________ test_api_timedelta[mysql_pymysql_engine] ___________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_timedelta(conn, request): 1430s # see #6921 1430s conn_name = conn 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_timedelta", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1897: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ____________________ test_api_timedelta[mysql_pymysql_conn] ____________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_timedelta(conn, request): 1430s # see #6921 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1896: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ________________ test_api_timedelta[postgresql_psycopg2_engine] ________________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_timedelta(conn, request): 1430s # see #6921 1430s conn_name = conn 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_timedelta", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1897: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _________________ test_api_timedelta[postgresql_psycopg2_conn] _________________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_timedelta(conn, request): 1430s # see #6921 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1896: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ________________ test_api_complex_raises[mysql_pymysql_engine] _________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_complex_raises(conn, request): 1430s conn_name = conn 1430s conn = request.getfixturevalue(conn) 1430s df = DataFrame({"a": [1 + 1j, 2j]}) 1430s 1430s if "adbc" in conn_name: 1430s msg = "datatypes not supported" 1430s else: 1430s msg = "Complex datatypes not supported" 1430s with pytest.raises(ValueError, match=msg): 1430s > assert df.to_sql("test_complex", con=conn) is None 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1950: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1430s return func(*args, **kwargs) 1430s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1430s return sql.to_sql( 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1430s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _________________ test_api_complex_raises[mysql_pymysql_conn] __________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_complex_raises(conn, request): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1942: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _____________ test_api_complex_raises[postgresql_psycopg2_engine] ______________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_complex_raises(conn, request): 1430s conn_name = conn 1430s conn = request.getfixturevalue(conn) 1430s df = DataFrame({"a": [1 + 1j, 2j]}) 1430s 1430s if "adbc" in conn_name: 1430s msg = "datatypes not supported" 1430s else: 1430s msg = "Complex datatypes not supported" 1430s with pytest.raises(ValueError, match=msg): 1430s > assert df.to_sql("test_complex", con=conn) is None 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1950: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1430s return func(*args, **kwargs) 1430s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1430s return sql.to_sql( 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1430s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ______________ test_api_complex_raises[postgresql_psycopg2_conn] _______________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_complex_raises(conn, request): 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1942: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ______ test_api_to_sql_index_label[None-None-index-mysql_pymysql_engine] _______ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s index_name = None, index_label = None, expected = 'index' 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "index_name,index_label,expected", 1430s [ 1430s # no index name, defaults to 'index' 1430s (None, None, "index"), 1430s # specifying index_label 1430s (None, "other_label", "other_label"), 1430s # using the index name 1430s ("index_name", None, "index_name"), 1430s # has index name, but specifying index_label 1430s ("index_name", "other_label", "other_label"), 1430s # index name is integer 1430s (0, None, "0"), 1430s # index name is None but index label is integer 1430s (None, 0, "0"), 1430s ], 1430s ) 1430s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1430s ) 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_index_label", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _______ test_api_to_sql_index_label[None-None-index-mysql_pymysql_conn] ________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s index_name = None, index_label = None, expected = 'index' 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "index_name,index_label,expected", 1430s [ 1430s # no index name, defaults to 'index' 1430s (None, None, "index"), 1430s # specifying index_label 1430s (None, "other_label", "other_label"), 1430s # using the index name 1430s ("index_name", None, "index_name"), 1430s # has index name, but specifying index_label 1430s ("index_name", "other_label", "other_label"), 1430s # index name is integer 1430s (0, None, "0"), 1430s # index name is None but index label is integer 1430s (None, 0, "0"), 1430s ], 1430s ) 1430s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1430s ) 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ___ test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_engine] ____ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s index_name = None, index_label = None, expected = 'index' 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "index_name,index_label,expected", 1430s [ 1430s # no index name, defaults to 'index' 1430s (None, None, "index"), 1430s # specifying index_label 1430s (None, "other_label", "other_label"), 1430s # using the index name 1430s ("index_name", None, "index_name"), 1430s # has index name, but specifying index_label 1430s ("index_name", "other_label", "other_label"), 1430s # index name is integer 1430s (0, None, "0"), 1430s # index name is None but index label is integer 1430s (None, 0, "0"), 1430s ], 1430s ) 1430s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1430s ) 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_index_label", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ____ test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_conn] _____ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s index_name = None, index_label = None, expected = 'index' 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "index_name,index_label,expected", 1430s [ 1430s # no index name, defaults to 'index' 1430s (None, None, "index"), 1430s # specifying index_label 1430s (None, "other_label", "other_label"), 1430s # using the index name 1430s ("index_name", None, "index_name"), 1430s # has index name, but specifying index_label 1430s ("index_name", "other_label", "other_label"), 1430s # index name is integer 1430s (0, None, "0"), 1430s # index name is None but index label is integer 1430s (None, 0, "0"), 1430s ], 1430s ) 1430s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1430s ) 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _ test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_engine] _ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s index_name = None, index_label = 'other_label', expected = 'other_label' 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "index_name,index_label,expected", 1430s [ 1430s # no index name, defaults to 'index' 1430s (None, None, "index"), 1430s # specifying index_label 1430s (None, "other_label", "other_label"), 1430s # using the index name 1430s ("index_name", None, "index_name"), 1430s # has index name, but specifying index_label 1430s ("index_name", "other_label", "other_label"), 1430s # index name is integer 1430s (0, None, "0"), 1430s # index name is None but index label is integer 1430s (None, 0, "0"), 1430s ], 1430s ) 1430s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1430s ) 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_index_label", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _ test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_conn] _ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s index_name = None, index_label = 'other_label', expected = 'other_label' 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "index_name,index_label,expected", 1430s [ 1430s # no index name, defaults to 'index' 1430s (None, None, "index"), 1430s # specifying index_label 1430s (None, "other_label", "other_label"), 1430s # using the index name 1430s ("index_name", None, "index_name"), 1430s # has index name, but specifying index_label 1430s ("index_name", "other_label", "other_label"), 1430s # index name is integer 1430s (0, None, "0"), 1430s # index name is None but index label is integer 1430s (None, 0, "0"), 1430s ], 1430s ) 1430s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1430s ) 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _ test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_engine] _ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s index_name = None, index_label = 'other_label', expected = 'other_label' 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "index_name,index_label,expected", 1430s [ 1430s # no index name, defaults to 'index' 1430s (None, None, "index"), 1430s # specifying index_label 1430s (None, "other_label", "other_label"), 1430s # using the index name 1430s ("index_name", None, "index_name"), 1430s # has index name, but specifying index_label 1430s ("index_name", "other_label", "other_label"), 1430s # index name is integer 1430s (0, None, "0"), 1430s # index name is None but index label is integer 1430s (None, 0, "0"), 1430s ], 1430s ) 1430s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1430s ) 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_index_label", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _ test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_conn] _ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s index_name = None, index_label = 'other_label', expected = 'other_label' 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "index_name,index_label,expected", 1430s [ 1430s # no index name, defaults to 'index' 1430s (None, None, "index"), 1430s # specifying index_label 1430s (None, "other_label", "other_label"), 1430s # using the index name 1430s ("index_name", None, "index_name"), 1430s # has index name, but specifying index_label 1430s ("index_name", "other_label", "other_label"), 1430s # index name is integer 1430s (0, None, "0"), 1430s # index name is None but index label is integer 1430s (None, 0, "0"), 1430s ], 1430s ) 1430s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1430s ) 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _ test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_engine] _ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s index_name = 'index_name', index_label = None, expected = 'index_name' 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "index_name,index_label,expected", 1430s [ 1430s # no index name, defaults to 'index' 1430s (None, None, "index"), 1430s # specifying index_label 1430s (None, "other_label", "other_label"), 1430s # using the index name 1430s ("index_name", None, "index_name"), 1430s # has index name, but specifying index_label 1430s ("index_name", "other_label", "other_label"), 1430s # index name is integer 1430s (0, None, "0"), 1430s # index name is None but index label is integer 1430s (None, 0, "0"), 1430s ], 1430s ) 1430s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1430s ) 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_index_label", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s __ test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_conn] __ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s index_name = 'index_name', index_label = None, expected = 'index_name' 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "index_name,index_label,expected", 1430s [ 1430s # no index name, defaults to 'index' 1430s (None, None, "index"), 1430s # specifying index_label 1430s (None, "other_label", "other_label"), 1430s # using the index name 1430s ("index_name", None, "index_name"), 1430s # has index name, but specifying index_label 1430s ("index_name", "other_label", "other_label"), 1430s # index name is integer 1430s (0, None, "0"), 1430s # index name is None but index label is integer 1430s (None, 0, "0"), 1430s ], 1430s ) 1430s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1430s ) 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _ test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_engine] _ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s index_name = 'index_name', index_label = None, expected = 'index_name' 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "index_name,index_label,expected", 1430s [ 1430s # no index name, defaults to 'index' 1430s (None, None, "index"), 1430s # specifying index_label 1430s (None, "other_label", "other_label"), 1430s # using the index name 1430s ("index_name", None, "index_name"), 1430s # has index name, but specifying index_label 1430s ("index_name", "other_label", "other_label"), 1430s # index name is integer 1430s (0, None, "0"), 1430s # index name is None but index label is integer 1430s (None, 0, "0"), 1430s ], 1430s ) 1430s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1430s ) 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_index_label", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _ test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_conn] _ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s index_name = 'index_name', index_label = None, expected = 'index_name' 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "index_name,index_label,expected", 1430s [ 1430s # no index name, defaults to 'index' 1430s (None, None, "index"), 1430s # specifying index_label 1430s (None, "other_label", "other_label"), 1430s # using the index name 1430s ("index_name", None, "index_name"), 1430s # has index name, but specifying index_label 1430s ("index_name", "other_label", "other_label"), 1430s # index name is integer 1430s (0, None, "0"), 1430s # index name is None but index label is integer 1430s (None, 0, "0"), 1430s ], 1430s ) 1430s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1430s ) 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _ test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_engine] _ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s index_name = 'index_name', index_label = 'other_label', expected = 'other_label' 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "index_name,index_label,expected", 1430s [ 1430s # no index name, defaults to 'index' 1430s (None, None, "index"), 1430s # specifying index_label 1430s (None, "other_label", "other_label"), 1430s # using the index name 1430s ("index_name", None, "index_name"), 1430s # has index name, but specifying index_label 1430s ("index_name", "other_label", "other_label"), 1430s # index name is integer 1430s (0, None, "0"), 1430s # index name is None but index label is integer 1430s (None, 0, "0"), 1430s ], 1430s ) 1430s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1430s ) 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_index_label", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _ test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_conn] _ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s index_name = 'index_name', index_label = 'other_label', expected = 'other_label' 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "index_name,index_label,expected", 1430s [ 1430s # no index name, defaults to 'index' 1430s (None, None, "index"), 1430s # specifying index_label 1430s (None, "other_label", "other_label"), 1430s # using the index name 1430s ("index_name", None, "index_name"), 1430s # has index name, but specifying index_label 1430s ("index_name", "other_label", "other_label"), 1430s # index name is integer 1430s (0, None, "0"), 1430s # index name is None but index label is integer 1430s (None, 0, "0"), 1430s ], 1430s ) 1430s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1430s ) 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _ test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_engine] _ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s index_name = 'index_name', index_label = 'other_label', expected = 'other_label' 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "index_name,index_label,expected", 1430s [ 1430s # no index name, defaults to 'index' 1430s (None, None, "index"), 1430s # specifying index_label 1430s (None, "other_label", "other_label"), 1430s # using the index name 1430s ("index_name", None, "index_name"), 1430s # has index name, but specifying index_label 1430s ("index_name", "other_label", "other_label"), 1430s # index name is integer 1430s (0, None, "0"), 1430s # index name is None but index label is integer 1430s (None, 0, "0"), 1430s ], 1430s ) 1430s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1430s ) 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_index_label", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _ test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_conn] _ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s index_name = 'index_name', index_label = 'other_label', expected = 'other_label' 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "index_name,index_label,expected", 1430s [ 1430s # no index name, defaults to 'index' 1430s (None, None, "index"), 1430s # specifying index_label 1430s (None, "other_label", "other_label"), 1430s # using the index name 1430s ("index_name", None, "index_name"), 1430s # has index name, but specifying index_label 1430s ("index_name", "other_label", "other_label"), 1430s # index name is integer 1430s (0, None, "0"), 1430s # index name is None but index label is integer 1430s (None, 0, "0"), 1430s ], 1430s ) 1430s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1430s ) 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s __________ test_api_to_sql_index_label[0-None-0-mysql_pymysql_engine] __________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s index_name = 0, index_label = None, expected = '0' 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "index_name,index_label,expected", 1430s [ 1430s # no index name, defaults to 'index' 1430s (None, None, "index"), 1430s # specifying index_label 1430s (None, "other_label", "other_label"), 1430s # using the index name 1430s ("index_name", None, "index_name"), 1430s # has index name, but specifying index_label 1430s ("index_name", "other_label", "other_label"), 1430s # index name is integer 1430s (0, None, "0"), 1430s # index name is None but index label is integer 1430s (None, 0, "0"), 1430s ], 1430s ) 1430s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1430s ) 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_index_label", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ___________ test_api_to_sql_index_label[0-None-0-mysql_pymysql_conn] ___________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s index_name = 0, index_label = None, expected = '0' 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "index_name,index_label,expected", 1430s [ 1430s # no index name, defaults to 'index' 1430s (None, None, "index"), 1430s # specifying index_label 1430s (None, "other_label", "other_label"), 1430s # using the index name 1430s ("index_name", None, "index_name"), 1430s # has index name, but specifying index_label 1430s ("index_name", "other_label", "other_label"), 1430s # index name is integer 1430s (0, None, "0"), 1430s # index name is None but index label is integer 1430s (None, 0, "0"), 1430s ], 1430s ) 1430s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1430s ) 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _______ test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_engine] _______ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s index_name = 0, index_label = None, expected = '0' 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "index_name,index_label,expected", 1430s [ 1430s # no index name, defaults to 'index' 1430s (None, None, "index"), 1430s # specifying index_label 1430s (None, "other_label", "other_label"), 1430s # using the index name 1430s ("index_name", None, "index_name"), 1430s # has index name, but specifying index_label 1430s ("index_name", "other_label", "other_label"), 1430s # index name is integer 1430s (0, None, "0"), 1430s # index name is None but index label is integer 1430s (None, 0, "0"), 1430s ], 1430s ) 1430s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1430s ) 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_index_label", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ________ test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_conn] ________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s index_name = 0, index_label = None, expected = '0' 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "index_name,index_label,expected", 1430s [ 1430s # no index name, defaults to 'index' 1430s (None, None, "index"), 1430s # specifying index_label 1430s (None, "other_label", "other_label"), 1430s # using the index name 1430s ("index_name", None, "index_name"), 1430s # has index name, but specifying index_label 1430s ("index_name", "other_label", "other_label"), 1430s # index name is integer 1430s (0, None, "0"), 1430s # index name is None but index label is integer 1430s (None, 0, "0"), 1430s ], 1430s ) 1430s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1430s ) 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s __________ test_api_to_sql_index_label[None-0-0-mysql_pymysql_engine] __________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s index_name = None, index_label = 0, expected = '0' 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "index_name,index_label,expected", 1430s [ 1430s # no index name, defaults to 'index' 1430s (None, None, "index"), 1430s # specifying index_label 1430s (None, "other_label", "other_label"), 1430s # using the index name 1430s ("index_name", None, "index_name"), 1430s # has index name, but specifying index_label 1430s ("index_name", "other_label", "other_label"), 1430s # index name is integer 1430s (0, None, "0"), 1430s # index name is None but index label is integer 1430s (None, 0, "0"), 1430s ], 1430s ) 1430s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1430s ) 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_index_label", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ___________ test_api_to_sql_index_label[None-0-0-mysql_pymysql_conn] ___________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s index_name = None, index_label = 0, expected = '0' 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "index_name,index_label,expected", 1430s [ 1430s # no index name, defaults to 'index' 1430s (None, None, "index"), 1430s # specifying index_label 1430s (None, "other_label", "other_label"), 1430s # using the index name 1430s ("index_name", None, "index_name"), 1430s # has index name, but specifying index_label 1430s ("index_name", "other_label", "other_label"), 1430s # index name is integer 1430s (0, None, "0"), 1430s # index name is None but index label is integer 1430s (None, 0, "0"), 1430s ], 1430s ) 1430s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1430s ) 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _______ test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_engine] _______ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s index_name = None, index_label = 0, expected = '0' 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "index_name,index_label,expected", 1430s [ 1430s # no index name, defaults to 'index' 1430s (None, None, "index"), 1430s # specifying index_label 1430s (None, "other_label", "other_label"), 1430s # using the index name 1430s ("index_name", None, "index_name"), 1430s # has index name, but specifying index_label 1430s ("index_name", "other_label", "other_label"), 1430s # index name is integer 1430s (0, None, "0"), 1430s # index name is None but index label is integer 1430s (None, 0, "0"), 1430s ], 1430s ) 1430s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1430s ) 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_index_label", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ________ test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_conn] ________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s index_name = None, index_label = 0, expected = '0' 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "index_name,index_label,expected", 1430s [ 1430s # no index name, defaults to 'index' 1430s (None, None, "index"), 1430s # specifying index_label 1430s (None, "other_label", "other_label"), 1430s # using the index name 1430s ("index_name", None, "index_name"), 1430s # has index name, but specifying index_label 1430s ("index_name", "other_label", "other_label"), 1430s # index name is integer 1430s (0, None, "0"), 1430s # index name is None but index label is integer 1430s (None, 0, "0"), 1430s ], 1430s ) 1430s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1430s ) 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ______ test_api_to_sql_index_label_multiindex[postgresql_psycopg2_engine] ______ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_to_sql_index_label_multiindex(conn, request): 1430s conn_name = conn 1430s if "mysql" in conn_name: 1430s request.applymarker( 1430s pytest.mark.xfail( 1430s reason="MySQL can fail using TEXT without length as key", strict=False 1430s ) 1430s ) 1430s elif "adbc" in conn_name: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1430s ) 1430s 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_index_label", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2004: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _______ test_api_to_sql_index_label_multiindex[postgresql_psycopg2_conn] _______ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_to_sql_index_label_multiindex(conn, request): 1430s conn_name = conn 1430s if "mysql" in conn_name: 1430s request.applymarker( 1430s pytest.mark.xfail( 1430s reason="MySQL can fail using TEXT without length as key", strict=False 1430s ) 1430s ) 1430s elif "adbc" in conn_name: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1430s ) 1430s 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2003: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _____________ test_api_multiindex_roundtrip[mysql_pymysql_engine] ______________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_multiindex_roundtrip(conn, request): 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_multiindex_roundtrip", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2066: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ______________ test_api_multiindex_roundtrip[mysql_pymysql_conn] _______________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_multiindex_roundtrip(conn, request): 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2065: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s __________ test_api_multiindex_roundtrip[postgresql_psycopg2_engine] ___________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_multiindex_roundtrip(conn, request): 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_multiindex_roundtrip", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2066: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ___________ test_api_multiindex_roundtrip[postgresql_psycopg2_conn] ____________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_multiindex_roundtrip(conn, request): 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2065: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ______________ test_api_dtype_argument[None-mysql_pymysql_engine] ______________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s dtype = None 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "dtype", 1430s [ 1430s None, 1430s int, 1430s float, 1430s {"A": int, "B": float}, 1430s ], 1430s ) 1430s def test_api_dtype_argument(conn, request, dtype): 1430s # GH10285 Add dtype argument to read_sql_query 1430s conn_name = conn 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_dtype_argument", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _______________ test_api_dtype_argument[None-mysql_pymysql_conn] _______________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s dtype = None 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "dtype", 1430s [ 1430s None, 1430s int, 1430s float, 1430s {"A": int, "B": float}, 1430s ], 1430s ) 1430s def test_api_dtype_argument(conn, request, dtype): 1430s # GH10285 Add dtype argument to read_sql_query 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ___________ test_api_dtype_argument[None-postgresql_psycopg2_engine] ___________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s dtype = None 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "dtype", 1430s [ 1430s None, 1430s int, 1430s float, 1430s {"A": int, "B": float}, 1430s ], 1430s ) 1430s def test_api_dtype_argument(conn, request, dtype): 1430s # GH10285 Add dtype argument to read_sql_query 1430s conn_name = conn 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_dtype_argument", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ____________ test_api_dtype_argument[None-postgresql_psycopg2_conn] ____________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s dtype = None 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "dtype", 1430s [ 1430s None, 1430s int, 1430s float, 1430s {"A": int, "B": float}, 1430s ], 1430s ) 1430s def test_api_dtype_argument(conn, request, dtype): 1430s # GH10285 Add dtype argument to read_sql_query 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ______________ test_api_dtype_argument[int-mysql_pymysql_engine] _______________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s dtype = 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "dtype", 1430s [ 1430s None, 1430s int, 1430s float, 1430s {"A": int, "B": float}, 1430s ], 1430s ) 1430s def test_api_dtype_argument(conn, request, dtype): 1430s # GH10285 Add dtype argument to read_sql_query 1430s conn_name = conn 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_dtype_argument", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _______________ test_api_dtype_argument[int-mysql_pymysql_conn] ________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s dtype = 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "dtype", 1430s [ 1430s None, 1430s int, 1430s float, 1430s {"A": int, "B": float}, 1430s ], 1430s ) 1430s def test_api_dtype_argument(conn, request, dtype): 1430s # GH10285 Add dtype argument to read_sql_query 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ___________ test_api_dtype_argument[int-postgresql_psycopg2_engine] ____________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s dtype = 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "dtype", 1430s [ 1430s None, 1430s int, 1430s float, 1430s {"A": int, "B": float}, 1430s ], 1430s ) 1430s def test_api_dtype_argument(conn, request, dtype): 1430s # GH10285 Add dtype argument to read_sql_query 1430s conn_name = conn 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_dtype_argument", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ____________ test_api_dtype_argument[int-postgresql_psycopg2_conn] _____________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s dtype = 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "dtype", 1430s [ 1430s None, 1430s int, 1430s float, 1430s {"A": int, "B": float}, 1430s ], 1430s ) 1430s def test_api_dtype_argument(conn, request, dtype): 1430s # GH10285 Add dtype argument to read_sql_query 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _____________ test_api_dtype_argument[float-mysql_pymysql_engine] ______________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s dtype = 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "dtype", 1430s [ 1430s None, 1430s int, 1430s float, 1430s {"A": int, "B": float}, 1430s ], 1430s ) 1430s def test_api_dtype_argument(conn, request, dtype): 1430s # GH10285 Add dtype argument to read_sql_query 1430s conn_name = conn 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_dtype_argument", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ______________ test_api_dtype_argument[float-mysql_pymysql_conn] _______________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s dtype = 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "dtype", 1430s [ 1430s None, 1430s int, 1430s float, 1430s {"A": int, "B": float}, 1430s ], 1430s ) 1430s def test_api_dtype_argument(conn, request, dtype): 1430s # GH10285 Add dtype argument to read_sql_query 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s __________ test_api_dtype_argument[float-postgresql_psycopg2_engine] ___________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s dtype = 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "dtype", 1430s [ 1430s None, 1430s int, 1430s float, 1430s {"A": int, "B": float}, 1430s ], 1430s ) 1430s def test_api_dtype_argument(conn, request, dtype): 1430s # GH10285 Add dtype argument to read_sql_query 1430s conn_name = conn 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_dtype_argument", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ___________ test_api_dtype_argument[float-postgresql_psycopg2_conn] ____________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s dtype = 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "dtype", 1430s [ 1430s None, 1430s int, 1430s float, 1430s {"A": int, "B": float}, 1430s ], 1430s ) 1430s def test_api_dtype_argument(conn, request, dtype): 1430s # GH10285 Add dtype argument to read_sql_query 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _____________ test_api_dtype_argument[dtype3-mysql_pymysql_engine] _____________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s dtype = {'A': , 'B': } 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "dtype", 1430s [ 1430s None, 1430s int, 1430s float, 1430s {"A": int, "B": float}, 1430s ], 1430s ) 1430s def test_api_dtype_argument(conn, request, dtype): 1430s # GH10285 Add dtype argument to read_sql_query 1430s conn_name = conn 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_dtype_argument", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ______________ test_api_dtype_argument[dtype3-mysql_pymysql_conn] ______________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s dtype = {'A': , 'B': } 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "dtype", 1430s [ 1430s None, 1430s int, 1430s float, 1430s {"A": int, "B": float}, 1430s ], 1430s ) 1430s def test_api_dtype_argument(conn, request, dtype): 1430s # GH10285 Add dtype argument to read_sql_query 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s __________ test_api_dtype_argument[dtype3-postgresql_psycopg2_engine] __________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s dtype = {'A': , 'B': } 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "dtype", 1430s [ 1430s None, 1430s int, 1430s float, 1430s {"A": int, "B": float}, 1430s ], 1430s ) 1430s def test_api_dtype_argument(conn, request, dtype): 1430s # GH10285 Add dtype argument to read_sql_query 1430s conn_name = conn 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_dtype_argument", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ___________ test_api_dtype_argument[dtype3-postgresql_psycopg2_conn] ___________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s dtype = {'A': , 'B': } 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s @pytest.mark.parametrize( 1430s "dtype", 1430s [ 1430s None, 1430s int, 1430s float, 1430s {"A": int, "B": float}, 1430s ], 1430s ) 1430s def test_api_dtype_argument(conn, request, dtype): 1430s # GH10285 Add dtype argument to read_sql_query 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _______________ test_api_integer_col_names[mysql_pymysql_engine] _______________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_integer_col_names(conn, request): 1430s conn = request.getfixturevalue(conn) 1430s df = DataFrame([[1, 2], [3, 4]], columns=[0, 1]) 1430s > sql.to_sql(df, "test_frame_integer_col_names", conn, if_exists="replace") 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2119: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1430s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ________________ test_api_integer_col_names[mysql_pymysql_conn] ________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_integer_col_names(conn, request): 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2117: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ____________ test_api_integer_col_names[postgresql_psycopg2_engine] ____________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_integer_col_names(conn, request): 1430s conn = request.getfixturevalue(conn) 1430s df = DataFrame([[1, 2], [3, 4]], columns=[0, 1]) 1430s > sql.to_sql(df, "test_frame_integer_col_names", conn, if_exists="replace") 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2119: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1430s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _____________ test_api_integer_col_names[postgresql_psycopg2_conn] _____________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_integer_col_names(conn, request): 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2117: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s __________________ test_api_get_schema[mysql_pymysql_engine] ___________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_get_schema(conn, request, test_frame1): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail( 1430s reason="'get_schema' not implemented for ADBC drivers", 1430s strict=True, 1430s ) 1430s ) 1430s conn = request.getfixturevalue(conn) 1430s > create_sql = sql.get_schema(test_frame1, "test", con=conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2132: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 1430s with pandasSQL_builder(con=con) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ___________________ test_api_get_schema[mysql_pymysql_conn] ____________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_get_schema(conn, request, test_frame1): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail( 1430s reason="'get_schema' not implemented for ADBC drivers", 1430s strict=True, 1430s ) 1430s ) 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2131: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _______________ test_api_get_schema[postgresql_psycopg2_engine] ________________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_get_schema(conn, request, test_frame1): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail( 1430s reason="'get_schema' not implemented for ADBC drivers", 1430s strict=True, 1430s ) 1430s ) 1430s conn = request.getfixturevalue(conn) 1430s > create_sql = sql.get_schema(test_frame1, "test", con=conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2132: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 1430s with pandasSQL_builder(con=con) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ________________ test_api_get_schema[postgresql_psycopg2_conn] _________________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_get_schema(conn, request, test_frame1): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail( 1430s reason="'get_schema' not implemented for ADBC drivers", 1430s strict=True, 1430s ) 1430s ) 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2131: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ____________ test_api_get_schema_with_schema[mysql_pymysql_engine] _____________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_get_schema_with_schema(conn, request, test_frame1): 1430s # GH28486 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail( 1430s reason="'get_schema' not implemented for ADBC drivers", 1430s strict=True, 1430s ) 1430s ) 1430s conn = request.getfixturevalue(conn) 1430s > create_sql = sql.get_schema(test_frame1, "test", con=conn, schema="pypi") 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2147: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 1430s with pandasSQL_builder(con=con) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _____________ test_api_get_schema_with_schema[mysql_pymysql_conn] ______________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_get_schema_with_schema(conn, request, test_frame1): 1430s # GH28486 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail( 1430s reason="'get_schema' not implemented for ADBC drivers", 1430s strict=True, 1430s ) 1430s ) 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _________ test_api_get_schema_with_schema[postgresql_psycopg2_engine] __________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_get_schema_with_schema(conn, request, test_frame1): 1430s # GH28486 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail( 1430s reason="'get_schema' not implemented for ADBC drivers", 1430s strict=True, 1430s ) 1430s ) 1430s conn = request.getfixturevalue(conn) 1430s > create_sql = sql.get_schema(test_frame1, "test", con=conn, schema="pypi") 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2147: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 1430s with pandasSQL_builder(con=con) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s __________ test_api_get_schema_with_schema[postgresql_psycopg2_conn] ___________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_get_schema_with_schema(conn, request, test_frame1): 1430s # GH28486 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail( 1430s reason="'get_schema' not implemented for ADBC drivers", 1430s strict=True, 1430s ) 1430s ) 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _______________ test_api_get_schema_dtypes[mysql_pymysql_engine] _______________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_get_schema_dtypes(conn, request): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail( 1430s reason="'get_schema' not implemented for ADBC drivers", 1430s strict=True, 1430s ) 1430s ) 1430s conn_name = conn 1430s conn = request.getfixturevalue(conn) 1430s float_frame = DataFrame({"a": [1.1, 1.2], "b": [2.1, 2.2]}) 1430s 1430s if conn_name == "sqlite_buildin": 1430s dtype = "INTEGER" 1430s else: 1430s from sqlalchemy import Integer 1430s 1430s dtype = Integer 1430s > create_sql = sql.get_schema(float_frame, "test", con=conn, dtype={"b": dtype}) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2170: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 1430s with pandasSQL_builder(con=con) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ________________ test_api_get_schema_dtypes[mysql_pymysql_conn] ________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_get_schema_dtypes(conn, request): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail( 1430s reason="'get_schema' not implemented for ADBC drivers", 1430s strict=True, 1430s ) 1430s ) 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2161: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ____________ test_api_get_schema_dtypes[postgresql_psycopg2_engine] ____________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_get_schema_dtypes(conn, request): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail( 1430s reason="'get_schema' not implemented for ADBC drivers", 1430s strict=True, 1430s ) 1430s ) 1430s conn_name = conn 1430s conn = request.getfixturevalue(conn) 1430s float_frame = DataFrame({"a": [1.1, 1.2], "b": [2.1, 2.2]}) 1430s 1430s if conn_name == "sqlite_buildin": 1430s dtype = "INTEGER" 1430s else: 1430s from sqlalchemy import Integer 1430s 1430s dtype = Integer 1430s > create_sql = sql.get_schema(float_frame, "test", con=conn, dtype={"b": dtype}) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2170: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 1430s with pandasSQL_builder(con=con) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _____________ test_api_get_schema_dtypes[postgresql_psycopg2_conn] _____________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_get_schema_dtypes(conn, request): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail( 1430s reason="'get_schema' not implemented for ADBC drivers", 1430s strict=True, 1430s ) 1430s ) 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2161: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ________________ test_api_get_schema_keys[mysql_pymysql_engine] ________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_get_schema_keys(conn, request, test_frame1): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail( 1430s reason="'get_schema' not implemented for ADBC drivers", 1430s strict=True, 1430s ) 1430s ) 1430s conn_name = conn 1430s conn = request.getfixturevalue(conn) 1430s frame = DataFrame({"Col1": [1.1, 1.2], "Col2": [2.1, 2.2]}) 1430s > create_sql = sql.get_schema(frame, "test", con=conn, keys="Col1") 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2187: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 1430s with pandasSQL_builder(con=con) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _________________ test_api_get_schema_keys[mysql_pymysql_conn] _________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_get_schema_keys(conn, request, test_frame1): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail( 1430s reason="'get_schema' not implemented for ADBC drivers", 1430s strict=True, 1430s ) 1430s ) 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2185: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _____________ test_api_get_schema_keys[postgresql_psycopg2_engine] _____________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_get_schema_keys(conn, request, test_frame1): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail( 1430s reason="'get_schema' not implemented for ADBC drivers", 1430s strict=True, 1430s ) 1430s ) 1430s conn_name = conn 1430s conn = request.getfixturevalue(conn) 1430s frame = DataFrame({"Col1": [1.1, 1.2], "Col2": [2.1, 2.2]}) 1430s > create_sql = sql.get_schema(frame, "test", con=conn, keys="Col1") 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2187: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 1430s with pandasSQL_builder(con=con) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ______________ test_api_get_schema_keys[postgresql_psycopg2_conn] ______________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_get_schema_keys(conn, request, test_frame1): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail( 1430s reason="'get_schema' not implemented for ADBC drivers", 1430s strict=True, 1430s ) 1430s ) 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2185: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ________________ test_api_chunksize_read[mysql_pymysql_engine] _________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_chunksize_read(conn, request): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1430s ) 1430s conn_name = conn 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_chunksize", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2212: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _________________ test_api_chunksize_read[mysql_pymysql_conn] __________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_chunksize_read(conn, request): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1430s ) 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2211: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _____________ test_api_chunksize_read[postgresql_psycopg2_engine] ______________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_chunksize_read(conn, request): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1430s ) 1430s conn_name = conn 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_chunksize", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2212: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ______________ test_api_chunksize_read[postgresql_psycopg2_conn] _______________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_chunksize_read(conn, request): 1430s if "adbc" in conn: 1430s request.node.add_marker( 1430s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1430s ) 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2211: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s __________________ test_api_categorical[mysql_pymysql_engine] __________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_categorical(conn, request): 1430s if conn == "postgresql_adbc_conn": 1430s adbc = import_optional_dependency("adbc_driver_postgresql", errors="ignore") 1430s if adbc is not None and Version(adbc.__version__) < Version("0.9.0"): 1430s request.node.add_marker( 1430s pytest.mark.xfail( 1430s reason="categorical dtype not implemented for ADBC postgres driver", 1430s strict=True, 1430s ) 1430s ) 1430s # GH8624 1430s # test that categorical gets written correctly as dense column 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_categorical", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2267: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ___________________ test_api_categorical[mysql_pymysql_conn] ___________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_categorical(conn, request): 1430s if conn == "postgresql_adbc_conn": 1430s adbc = import_optional_dependency("adbc_driver_postgresql", errors="ignore") 1430s if adbc is not None and Version(adbc.__version__) < Version("0.9.0"): 1430s request.node.add_marker( 1430s pytest.mark.xfail( 1430s reason="categorical dtype not implemented for ADBC postgres driver", 1430s strict=True, 1430s ) 1430s ) 1430s # GH8624 1430s # test that categorical gets written correctly as dense column 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2266: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _______________ test_api_categorical[postgresql_psycopg2_engine] _______________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_categorical(conn, request): 1430s if conn == "postgresql_adbc_conn": 1430s adbc = import_optional_dependency("adbc_driver_postgresql", errors="ignore") 1430s if adbc is not None and Version(adbc.__version__) < Version("0.9.0"): 1430s request.node.add_marker( 1430s pytest.mark.xfail( 1430s reason="categorical dtype not implemented for ADBC postgres driver", 1430s strict=True, 1430s ) 1430s ) 1430s # GH8624 1430s # test that categorical gets written correctly as dense column 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_categorical", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2267: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ________________ test_api_categorical[postgresql_psycopg2_conn] ________________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_categorical(conn, request): 1430s if conn == "postgresql_adbc_conn": 1430s adbc = import_optional_dependency("adbc_driver_postgresql", errors="ignore") 1430s if adbc is not None and Version(adbc.__version__) < Version("0.9.0"): 1430s request.node.add_marker( 1430s pytest.mark.xfail( 1430s reason="categorical dtype not implemented for ADBC postgres driver", 1430s strict=True, 1430s ) 1430s ) 1430s # GH8624 1430s # test that categorical gets written correctly as dense column 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2266: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ______________ test_api_unicode_column_name[mysql_pymysql_engine] ______________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_unicode_column_name(conn, request): 1430s # GH 11431 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_unicode", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2290: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _______________ test_api_unicode_column_name[mysql_pymysql_conn] _______________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_unicode_column_name(conn, request): 1430s # GH 11431 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2289: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ___________ test_api_unicode_column_name[postgresql_psycopg2_engine] ___________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_unicode_column_name(conn, request): 1430s # GH 11431 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_unicode", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2290: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ____________ test_api_unicode_column_name[postgresql_psycopg2_conn] ____________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_unicode_column_name(conn, request): 1430s # GH 11431 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2289: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ______________ test_api_escaped_table_name[mysql_pymysql_engine] _______________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_escaped_table_name(conn, request): 1430s # GH 13206 1430s conn_name = conn 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("d1187b08-4943-4c8d-a7f6", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2303: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _______________ test_api_escaped_table_name[mysql_pymysql_conn] ________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_escaped_table_name(conn, request): 1430s # GH 13206 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2302: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ___________ test_api_escaped_table_name[postgresql_psycopg2_engine] ____________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_escaped_table_name(conn, request): 1430s # GH 13206 1430s conn_name = conn 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("d1187b08-4943-4c8d-a7f6", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2303: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ____________ test_api_escaped_table_name[postgresql_psycopg2_conn] _____________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_escaped_table_name(conn, request): 1430s # GH 13206 1430s conn_name = conn 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2302: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s __________ test_api_read_sql_duplicate_columns[mysql_pymysql_engine] ___________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_read_sql_duplicate_columns(conn, request): 1430s # GH#53117 1430s if "adbc" in conn: 1430s pa = pytest.importorskip("pyarrow") 1430s if not ( 1430s Version(pa.__version__) >= Version("16.0") 1430s and conn in ["sqlite_adbc_conn", "postgresql_adbc_conn"] 1430s ): 1430s request.node.add_marker( 1430s pytest.mark.xfail( 1430s reason="pyarrow->pandas throws ValueError", strict=True 1430s ) 1430s ) 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_table", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2334: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ___________ test_api_read_sql_duplicate_columns[mysql_pymysql_conn] ____________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_read_sql_duplicate_columns(conn, request): 1430s # GH#53117 1430s if "adbc" in conn: 1430s pa = pytest.importorskip("pyarrow") 1430s if not ( 1430s Version(pa.__version__) >= Version("16.0") 1430s and conn in ["sqlite_adbc_conn", "postgresql_adbc_conn"] 1430s ): 1430s request.node.add_marker( 1430s pytest.mark.xfail( 1430s reason="pyarrow->pandas throws ValueError", strict=True 1430s ) 1430s ) 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2333: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _______ test_api_read_sql_duplicate_columns[postgresql_psycopg2_engine] ________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_read_sql_duplicate_columns(conn, request): 1430s # GH#53117 1430s if "adbc" in conn: 1430s pa = pytest.importorskip("pyarrow") 1430s if not ( 1430s Version(pa.__version__) >= Version("16.0") 1430s and conn in ["sqlite_adbc_conn", "postgresql_adbc_conn"] 1430s ): 1430s request.node.add_marker( 1430s pytest.mark.xfail( 1430s reason="pyarrow->pandas throws ValueError", strict=True 1430s ) 1430s ) 1430s conn = request.getfixturevalue(conn) 1430s > if sql.has_table("test_table", conn): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2334: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1430s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ________ test_api_read_sql_duplicate_columns[postgresql_psycopg2_conn] _________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_api_read_sql_duplicate_columns(conn, request): 1430s # GH#53117 1430s if "adbc" in conn: 1430s pa = pytest.importorskip("pyarrow") 1430s if not ( 1430s Version(pa.__version__) >= Version("16.0") 1430s and conn in ["sqlite_adbc_conn", "postgresql_adbc_conn"] 1430s ): 1430s request.node.add_marker( 1430s pytest.mark.xfail( 1430s reason="pyarrow->pandas throws ValueError", strict=True 1430s ) 1430s ) 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2333: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ________________ test_read_table_columns[mysql_pymysql_engine] _________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_read_table_columns(conn, request, test_frame1): 1430s # test columns argument in read_table 1430s conn_name = conn 1430s if conn_name == "sqlite_buildin": 1430s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1430s 1430s conn = request.getfixturevalue(conn) 1430s > sql.to_sql(test_frame1, "test_frame", conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2357: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1430s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _________________ test_read_table_columns[mysql_pymysql_conn] __________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_read_table_columns(conn, request, test_frame1): 1430s # test columns argument in read_table 1430s conn_name = conn 1430s if conn_name == "sqlite_buildin": 1430s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1430s 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2356: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _____________ test_read_table_columns[postgresql_psycopg2_engine] ______________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_read_table_columns(conn, request, test_frame1): 1430s # test columns argument in read_table 1430s conn_name = conn 1430s if conn_name == "sqlite_buildin": 1430s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1430s 1430s conn = request.getfixturevalue(conn) 1430s > sql.to_sql(test_frame1, "test_frame", conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2357: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1430s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ______________ test_read_table_columns[postgresql_psycopg2_conn] _______________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_read_table_columns(conn, request, test_frame1): 1430s # test columns argument in read_table 1430s conn_name = conn 1430s if conn_name == "sqlite_buildin": 1430s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1430s 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2356: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _______________ test_read_table_index_col[mysql_pymysql_engine] ________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_read_table_index_col(conn, request, test_frame1): 1430s # test columns argument in read_table 1430s conn_name = conn 1430s if conn_name == "sqlite_buildin": 1430s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1430s 1430s conn = request.getfixturevalue(conn) 1430s > sql.to_sql(test_frame1, "test_frame", conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2373: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1430s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ________________ test_read_table_index_col[mysql_pymysql_conn] _________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_read_table_index_col(conn, request, test_frame1): 1430s # test columns argument in read_table 1430s conn_name = conn 1430s if conn_name == "sqlite_buildin": 1430s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1430s 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2372: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ____________ test_read_table_index_col[postgresql_psycopg2_engine] _____________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_read_table_index_col(conn, request, test_frame1): 1430s # test columns argument in read_table 1430s conn_name = conn 1430s if conn_name == "sqlite_buildin": 1430s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1430s 1430s conn = request.getfixturevalue(conn) 1430s > sql.to_sql(test_frame1, "test_frame", conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2373: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1430s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1430s return SQLDatabase(con, schema, need_transaction) 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s _____________ test_read_table_index_col[postgresql_psycopg2_conn] ______________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn' 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_read_table_index_col(conn, request, test_frame1): 1430s # test columns argument in read_table 1430s conn_name = conn 1430s if conn_name == "sqlite_buildin": 1430s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1430s 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2372: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1430s with postgresql_psycopg2_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ______________ test_read_sql_delegate[mysql_pymysql_engine_iris] _______________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_engine_iris' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_iris) 1430s def test_read_sql_delegate(conn, request): 1430s if conn == "sqlite_buildin_iris": 1430s request.applymarker( 1430s pytest.mark.xfail( 1430s reason="sqlite_buildin connection does not implement read_sql_table" 1430s ) 1430s ) 1430s 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2397: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1430s create_and_load_iris(mysql_pymysql_engine, iris_path) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1430s with conn.begin() as con: 1430s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1430s return next(self.gen) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1430s with self.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _______________ test_read_sql_delegate[mysql_pymysql_conn_iris] ________________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn_iris' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_iris) 1430s def test_read_sql_delegate(conn, request): 1430s if conn == "sqlite_buildin_iris": 1430s request.applymarker( 1430s pytest.mark.xfail( 1430s reason="sqlite_buildin connection does not implement read_sql_table" 1430s ) 1430s ) 1430s 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2397: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1430s create_and_load_iris(mysql_pymysql_engine, iris_path) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1430s with conn.begin() as con: 1430s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1430s return next(self.gen) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1430s with self.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s ___________ test_read_sql_delegate[postgresql_psycopg2_engine_iris] ____________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_engine_iris' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_iris) 1430s def test_read_sql_delegate(conn, request): 1430s if conn == "sqlite_buildin_iris": 1430s request.applymarker( 1430s pytest.mark.xfail( 1430s reason="sqlite_buildin connection does not implement read_sql_table" 1430s ) 1430s ) 1430s 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2397: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1430s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1430s with conn.begin() as con: 1430s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1430s return next(self.gen) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1430s with self.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ____________ test_read_sql_delegate[postgresql_psycopg2_conn_iris] _____________ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'postgresql_psycopg2_conn_iris' 1430s request = > 1430s 1430s @pytest.mark.parametrize("conn", all_connectable_iris) 1430s def test_read_sql_delegate(conn, request): 1430s if conn == "sqlite_buildin_iris": 1430s request.applymarker( 1430s pytest.mark.xfail( 1430s reason="sqlite_buildin connection does not implement read_sql_table" 1430s ) 1430s ) 1430s 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2397: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1430s fixturedef = request._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1430s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1430s with conn.begin() as con: 1430s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1430s return next(self.gen) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1430s with self.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s ________ test_warning_case_insensitive_table_name[mysql_pymysql_engine] ________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 1430s conn_name = conn 1430s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 1430s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 1430s 1430s conn = request.getfixturevalue(conn) 1430s # see gh-7815 1430s with tm.assert_produces_warning( 1430s UserWarning, 1430s match=( 1430s r"The provided table name 'TABLE1' is not found exactly as such in " 1430s r"the database after writing the table, possibly due to case " 1430s r"sensitivity issues. Consider using lower case table names." 1430s ), 1430s ): 1430s > with sql.SQLDatabase(conn) as db: 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2448: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 1430s conn_name = conn 1430s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 1430s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 1430s 1430s conn = request.getfixturevalue(conn) 1430s # see gh-7815 1430s > with tm.assert_produces_warning( 1430s UserWarning, 1430s match=( 1430s r"The provided table name 'TABLE1' is not found exactly as such in " 1430s r"the database after writing the table, possibly due to case " 1430s r"sensitivity issues. Consider using lower case table names." 1430s ), 1430s ): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2440: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/contextlib.py:162: in __exit__ 1430s self.gen.throw(value) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s def _assert_caught_expected_warning( 1430s *, 1430s caught_warnings: Sequence[warnings.WarningMessage], 1430s expected_warning: type[Warning], 1430s match: str | None, 1430s check_stacklevel: bool, 1430s ) -> None: 1430s """Assert that there was the expected warning among the caught warnings.""" 1430s saw_warning = False 1430s matched_message = False 1430s unmatched_messages = [] 1430s 1430s for actual_warning in caught_warnings: 1430s if issubclass(actual_warning.category, expected_warning): 1430s saw_warning = True 1430s 1430s if check_stacklevel: 1430s _assert_raised_with_correct_stacklevel(actual_warning) 1430s 1430s if match is not None: 1430s if re.search(match, str(actual_warning.message)): 1430s matched_message = True 1430s else: 1430s unmatched_messages.append(actual_warning.message) 1430s 1430s if not saw_warning: 1430s > raise AssertionError( 1430s f"Did not see expected warning of class " 1430s f"{repr(expected_warning.__name__)}" 1430s ) 1430s E AssertionError: Did not see expected warning of class 'UserWarning' 1430s 1430s /usr/lib/python3/dist-packages/pandas/_testing/_warnings.py:152: AssertionError 1430s _________ test_warning_case_insensitive_table_name[mysql_pymysql_conn] _________ 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s > sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/socket.py:864: in create_connection 1430s raise exceptions[0] 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s address = ('localhost', 3306), timeout = 10, source_address = None 1430s 1430s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1430s source_address=None, *, all_errors=False): 1430s """Connect to *address* and return the socket object. 1430s 1430s Convenience function. Connect to *address* (a 2-tuple ``(host, 1430s port)``) and return the socket object. Passing the optional 1430s *timeout* parameter will set the timeout on the socket instance 1430s before attempting to connect. If no *timeout* is supplied, the 1430s global default timeout setting returned by :func:`getdefaulttimeout` 1430s is used. If *source_address* is set it must be a tuple of (host, port) 1430s for the socket to bind as a source address before making the connection. 1430s A host of '' or port 0 tells the OS to use the default. When a connection 1430s cannot be created, raises the last error if *all_errors* is False, 1430s and an ExceptionGroup of all errors if *all_errors* is True. 1430s """ 1430s 1430s host, port = address 1430s exceptions = [] 1430s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1430s af, socktype, proto, canonname, sa = res 1430s sock = None 1430s try: 1430s sock = socket(af, socktype, proto) 1430s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1430s sock.settimeout(timeout) 1430s if source_address: 1430s sock.bind(source_address) 1430s > sock.connect(sa) 1430s E ConnectionRefusedError: [Errno 111] Connection refused 1430s 1430s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s self = 1430s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1430s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = 'mysql_pymysql_conn' 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 1430s conn_name = conn 1430s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 1430s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 1430s 1430s > conn = request.getfixturevalue(conn) 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2438: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1430s fixturedef = self._get_active_fixturedef(argname) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1430s fixturedef.execute(request=subrequest) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1430s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1430s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1430s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1430s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1430s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1430s return (yield) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1430s result = call_fixture_func(fixturefunc, request, kwargs) 1430s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1430s fixture_result = next(generator) 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1430s with mysql_pymysql_engine.connect() as conn: 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1430s self.connect() 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s self = , sock = None 1430s 1430s def connect(self, sock=None): 1430s self._closed = False 1430s try: 1430s if sock is None: 1430s if self.unix_socket: 1430s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1430s sock.settimeout(self.connect_timeout) 1430s sock.connect(self.unix_socket) 1430s self.host_info = "Localhost via UNIX socket" 1430s self._secure = True 1430s if DEBUG: 1430s print("connected using unix_socket") 1430s else: 1430s kwargs = {} 1430s if self.bind_address is not None: 1430s kwargs["source_address"] = (self.bind_address, 0) 1430s while True: 1430s try: 1430s sock = socket.create_connection( 1430s (self.host, self.port), self.connect_timeout, **kwargs 1430s ) 1430s break 1430s except OSError as e: 1430s if e.errno == errno.EINTR: 1430s continue 1430s raise 1430s self.host_info = "socket %s:%d" % (self.host, self.port) 1430s if DEBUG: 1430s print("connected using socket") 1430s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1430s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1430s sock.settimeout(None) 1430s 1430s self._sock = sock 1430s self._rfile = sock.makefile("rb") 1430s self._next_seq_id = 0 1430s 1430s self._get_server_information() 1430s self._request_authentication() 1430s 1430s # Send "SET NAMES" query on init for: 1430s # - Ensure charaset (and collation) is set to the server. 1430s # - collation_id in handshake packet may be ignored. 1430s # - If collation is not specified, we don't know what is server's 1430s # default collation for the charset. For example, default collation 1430s # of utf8mb4 is: 1430s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1430s # - MySQL 8.0: utf8mb4_0900_ai_ci 1430s # 1430s # Reference: 1430s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1430s # - https://github.com/wagtail/wagtail/issues/9477 1430s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1430s self.set_character_set(self.charset, self.collation) 1430s 1430s if self.sql_mode is not None: 1430s c = self.cursor() 1430s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1430s c.close() 1430s 1430s if self.init_command is not None: 1430s c = self.cursor() 1430s c.execute(self.init_command) 1430s c.close() 1430s 1430s if self.autocommit_mode is not None: 1430s self.autocommit(self.autocommit_mode) 1430s except BaseException as e: 1430s self._rfile = None 1430s if sock is not None: 1430s try: 1430s sock.close() 1430s except: # noqa 1430s pass 1430s 1430s if isinstance(e, (OSError, IOError)): 1430s exc = err.OperationalError( 1430s CR.CR_CONN_HOST_ERROR, 1430s f"Can't connect to MySQL server on {self.host!r} ({e})", 1430s ) 1430s # Keep original exception and traceback to investigate error. 1430s exc.original_exception = e 1430s exc.traceback = traceback.format_exc() 1430s if DEBUG: 1430s print(exc.traceback) 1430s > raise exc 1430s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1430s _____ test_warning_case_insensitive_table_name[postgresql_psycopg2_engine] _____ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s The above exception was the direct cause of the following exception: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 1430s conn_name = conn 1430s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 1430s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 1430s 1430s conn = request.getfixturevalue(conn) 1430s # see gh-7815 1430s with tm.assert_produces_warning( 1430s UserWarning, 1430s match=( 1430s r"The provided table name 'TABLE1' is not found exactly as such in " 1430s r"the database after writing the table, possibly due to case " 1430s r"sensitivity issues. Consider using lower case table names." 1430s ), 1430s ): 1430s > with sql.SQLDatabase(conn) as db: 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2448: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1430s con = self.exit_stack.enter_context(con.connect()) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1430s return self._connection_cls(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1430s Connection._handle_dbapi_exception_noconnection( 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1430s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1430s self._dbapi_connection = engine.raw_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1430s 1430s - *dbname*: the database name 1430s - *database*: the database name (only as keyword argument) 1430s - *user*: user name used to authenticate 1430s - *password*: password used to authenticate 1430s - *host*: database host address (defaults to UNIX socket if not provided) 1430s - *port*: connection port number (defaults to 5432 if not provided) 1430s 1430s Using the *connection_factory* parameter a different class or connections 1430s factory can be specified. It should be a callable object taking a dsn 1430s argument. 1430s 1430s Using the *cursor_factory* parameter, a new default cursor factory will be 1430s used by cursor(). 1430s 1430s Using *async*=True an asynchronous connection will be created. *async_* is 1430s a valid alias (for Python versions where ``async`` is a keyword). 1430s 1430s Any other keyword parameter will be passed to the underlying client 1430s library: the list of supported parameters depends on the library version. 1430s 1430s """ 1430s kwasync = {} 1430s if 'async' in kwargs: 1430s kwasync['async'] = kwargs.pop('async') 1430s if 'async_' in kwargs: 1430s kwasync['async_'] = kwargs.pop('async_') 1430s 1430s dsn = _ext.make_dsn(dsn, **kwargs) 1430s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1430s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1430s E Is the server running on that host and accepting TCP/IP connections? 1430s E 1430s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1430s 1430s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1430s 1430s During handling of the above exception, another exception occurred: 1430s 1430s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s request = > 1430s test_frame1 = index A B C D 1430s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1430s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1430s 1430s @pytest.mark.parametrize("conn", all_connectable) 1430s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 1430s conn_name = conn 1430s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 1430s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 1430s 1430s conn = request.getfixturevalue(conn) 1430s # see gh-7815 1430s > with tm.assert_produces_warning( 1430s UserWarning, 1430s match=( 1430s r"The provided table name 'TABLE1' is not found exactly as such in " 1430s r"the database after writing the table, possibly due to case " 1430s r"sensitivity issues. Consider using lower case table names." 1430s ), 1430s ): 1430s 1430s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2440: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3.13/contextlib.py:162: in __exit__ 1430s self.gen.throw(value) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s def _assert_caught_expected_warning( 1430s *, 1430s caught_warnings: Sequence[warnings.WarningMessage], 1430s expected_warning: type[Warning], 1430s match: str | None, 1430s check_stacklevel: bool, 1430s ) -> None: 1430s """Assert that there was the expected warning among the caught warnings.""" 1430s saw_warning = False 1430s matched_message = False 1430s unmatched_messages = [] 1430s 1430s for actual_warning in caught_warnings: 1430s if issubclass(actual_warning.category, expected_warning): 1430s saw_warning = True 1430s 1430s if check_stacklevel: 1430s _assert_raised_with_correct_stacklevel(actual_warning) 1430s 1430s if match is not None: 1430s if re.search(match, str(actual_warning.message)): 1430s matched_message = True 1430s else: 1430s unmatched_messages.append(actual_warning.message) 1430s 1430s if not saw_warning: 1430s > raise AssertionError( 1430s f"Did not see expected warning of class " 1430s f"{repr(expected_warning.__name__)}" 1430s ) 1430s E AssertionError: Did not see expected warning of class 'UserWarning' 1430s 1430s /usr/lib/python3/dist-packages/pandas/_testing/_warnings.py:152: AssertionError 1430s ______ test_warning_case_insensitive_table_name[postgresql_psycopg2_conn] ______ 1430s self = 1430s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1430s connection = None, _has_events = None, _allow_revalidate = True 1430s _allow_autobegin = True 1430s 1430s def __init__( 1430s self, 1430s engine: Engine, 1430s connection: Optional[PoolProxiedConnection] = None, 1430s _has_events: Optional[bool] = None, 1430s _allow_revalidate: bool = True, 1430s _allow_autobegin: bool = True, 1430s ): 1430s """Construct a new Connection.""" 1430s self.engine = engine 1430s self.dialect = dialect = engine.dialect 1430s 1430s if connection is None: 1430s try: 1430s > self._dbapi_connection = engine.raw_connection() 1430s 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1430s return self.pool.connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1430s return _ConnectionFairy._checkout(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1430s fairy = _ConnectionRecord.checkout(pool) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1430s rec = pool._do_get() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1430s return self._create_connection() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1430s return _ConnectionRecord(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1430s self.__connect() 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1430s with util.safe_reraise(): 1430s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1430s raise exc_value.with_traceback(exc_tb) 1430s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1430s self.dbapi_connection = connection = pool._invoke_creator(self) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1430s return dialect.connect(*cargs, **cparams) 1430s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1430s return self.loaded_dbapi.connect(*cargs, **cparams) 1430s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1430s 1430s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1430s connection_factory = None, cursor_factory = None 1430s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1430s kwasync = {} 1430s 1430s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1430s """ 1430s Create a new database connection. 1430s 1430s The connection parameters can be specified as a string: 1430s 1430s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1430s 1430s or using a set of keyword arguments: 1430s 1430s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1430s 1430s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s test_frame1 = index A B C D 1431s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1431s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1431s 1431s @pytest.mark.parametrize("conn", all_connectable) 1431s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 1431s conn_name = conn 1431s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 1431s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 1431s 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2438: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ______________ test_sqlalchemy_type_mapping[mysql_pymysql_engine] ______________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_sqlalchemy_type_mapping(conn, request): 1431s conn = request.getfixturevalue(conn) 1431s from sqlalchemy import TIMESTAMP 1431s 1431s # Test Timestamp objects (no datetime64 because of timezone) (GH9085) 1431s df = DataFrame( 1431s {"time": to_datetime(["2014-12-12 01:54", "2014-12-11 02:54"], utc=True)} 1431s ) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2465: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s _______________ test_sqlalchemy_type_mapping[mysql_pymysql_conn] _______________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_sqlalchemy_type_mapping(conn, request): 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2458: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ___________ test_sqlalchemy_type_mapping[postgresql_psycopg2_engine] ___________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_sqlalchemy_type_mapping(conn, request): 1431s conn = request.getfixturevalue(conn) 1431s from sqlalchemy import TIMESTAMP 1431s 1431s # Test Timestamp objects (no datetime64 because of timezone) (GH9085) 1431s df = DataFrame( 1431s {"time": to_datetime(["2014-12-12 01:54", "2014-12-11 02:54"], utc=True)} 1431s ) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2465: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ____________ test_sqlalchemy_type_mapping[postgresql_psycopg2_conn] ____________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_sqlalchemy_type_mapping(conn, request): 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2458: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _____ test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_engine] ______ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s integer = 'int8', expected = 'SMALLINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ______ test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_conn] _______ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s integer = 'int8', expected = 'SMALLINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s __ test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_engine] ___ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s integer = 'int8', expected = 'SMALLINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ___ test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_conn] ____ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s integer = 'int8', expected = 'SMALLINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _____ test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_engine] ______ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s integer = 'Int8', expected = 'SMALLINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ______ test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_conn] _______ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s integer = 'Int8', expected = 'SMALLINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s __ test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_engine] ___ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s integer = 'Int8', expected = 'SMALLINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ___ test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_conn] ____ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s integer = 'Int8', expected = 'SMALLINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _____ test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_engine] _____ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s integer = 'uint8', expected = 'SMALLINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ______ test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_conn] ______ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s integer = 'uint8', expected = 'SMALLINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s __ test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_engine] __ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s integer = 'uint8', expected = 'SMALLINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ___ test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_conn] ___ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s integer = 'uint8', expected = 'SMALLINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _____ test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_engine] _____ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s integer = 'UInt8', expected = 'SMALLINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ______ test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_conn] ______ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s integer = 'UInt8', expected = 'SMALLINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s __ test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_engine] __ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s integer = 'UInt8', expected = 'SMALLINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ___ test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_conn] ___ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s integer = 'UInt8', expected = 'SMALLINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _____ test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_engine] _____ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s integer = 'int16', expected = 'SMALLINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ______ test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_conn] ______ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s integer = 'int16', expected = 'SMALLINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s __ test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_engine] __ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s integer = 'int16', expected = 'SMALLINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ___ test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_conn] ___ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s integer = 'int16', expected = 'SMALLINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _____ test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_engine] _____ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s integer = 'Int16', expected = 'SMALLINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ______ test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_conn] ______ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s integer = 'Int16', expected = 'SMALLINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s __ test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_engine] __ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s integer = 'Int16', expected = 'SMALLINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ___ test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_conn] ___ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s integer = 'Int16', expected = 'SMALLINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _____ test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_engine] _____ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s integer = 'uint16', expected = 'INTEGER' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ______ test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_conn] ______ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s integer = 'uint16', expected = 'INTEGER' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s __ test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_engine] __ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s integer = 'uint16', expected = 'INTEGER' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ___ test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_conn] ___ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s integer = 'uint16', expected = 'INTEGER' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _____ test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_engine] _____ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s integer = 'UInt16', expected = 'INTEGER' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ______ test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_conn] ______ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s integer = 'UInt16', expected = 'INTEGER' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s __ test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_engine] __ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s integer = 'UInt16', expected = 'INTEGER' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ___ test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_conn] ___ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s integer = 'UInt16', expected = 'INTEGER' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _____ test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_engine] ______ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s integer = 'int32', expected = 'INTEGER' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ______ test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_conn] _______ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s integer = 'int32', expected = 'INTEGER' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s __ test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_engine] ___ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s integer = 'int32', expected = 'INTEGER' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ___ test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_conn] ____ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s integer = 'int32', expected = 'INTEGER' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _____ test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_engine] ______ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s integer = 'Int32', expected = 'INTEGER' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ______ test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_conn] _______ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s integer = 'Int32', expected = 'INTEGER' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s __ test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_engine] ___ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s integer = 'Int32', expected = 'INTEGER' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ___ test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_conn] ____ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s integer = 'Int32', expected = 'INTEGER' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _____ test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_engine] ______ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s integer = 'uint32', expected = 'BIGINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ______ test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_conn] _______ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s integer = 'uint32', expected = 'BIGINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s __ test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_engine] ___ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s integer = 'uint32', expected = 'BIGINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ___ test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_conn] ____ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s integer = 'uint32', expected = 'BIGINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _____ test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_engine] ______ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s integer = 'UInt32', expected = 'BIGINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ______ test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_conn] _______ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s integer = 'UInt32', expected = 'BIGINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s __ test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_engine] ___ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s integer = 'UInt32', expected = 'BIGINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ___ test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_conn] ____ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s integer = 'UInt32', expected = 'BIGINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ______ test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_engine] ______ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s integer = 'int64', expected = 'BIGINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s _______ test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_conn] _______ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s integer = 'int64', expected = 'BIGINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ___ test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_engine] ___ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s integer = 'int64', expected = 'BIGINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ____ test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_conn] ____ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s integer = 'int64', expected = 'BIGINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ______ test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_engine] ______ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s integer = 'Int64', expected = 'BIGINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s _______ test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_conn] _______ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s integer = 'Int64', expected = 'BIGINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ___ test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_engine] ___ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s integer = 'Int64', expected = 'BIGINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ____ test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_conn] ____ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s integer = 'Int64', expected = 'BIGINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _______ test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_engine] _______ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s integer = , expected = 'BIGINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ________ test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_conn] ________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s integer = , expected = 'BIGINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ____ test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_engine] ____ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s integer = , expected = 'BIGINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _____ test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_conn] _____ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s integer = , expected = 'BIGINT' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize( 1431s "integer, expected", 1431s [ 1431s ("int8", "SMALLINT"), 1431s ("Int8", "SMALLINT"), 1431s ("uint8", "SMALLINT"), 1431s ("UInt8", "SMALLINT"), 1431s ("int16", "SMALLINT"), 1431s ("Int16", "SMALLINT"), 1431s ("uint16", "INTEGER"), 1431s ("UInt16", "INTEGER"), 1431s ("int32", "INTEGER"), 1431s ("Int32", "INTEGER"), 1431s ("uint32", "BIGINT"), 1431s ("UInt32", "BIGINT"), 1431s ("int64", "BIGINT"), 1431s ("Int64", "BIGINT"), 1431s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1431s ], 1431s ) 1431s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ____ test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_engine] _____ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s integer = 'uint64' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 1431s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 1431s conn = request.getfixturevalue(conn) 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2509: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s _____ test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_conn] ______ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s integer = 'uint64' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 1431s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2506: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s _ test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_engine] __ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s integer = 'uint64' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 1431s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 1431s conn = request.getfixturevalue(conn) 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2509: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s __ test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_conn] ___ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s integer = 'uint64' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 1431s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2506: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ____ test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_engine] _____ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s integer = 'UInt64' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 1431s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 1431s conn = request.getfixturevalue(conn) 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2509: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s _____ test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_conn] ______ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s integer = 'UInt64' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 1431s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2506: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s _ test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_engine] __ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s integer = 'UInt64' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 1431s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 1431s conn = request.getfixturevalue(conn) 1431s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1431s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1431s > with sql.SQLDatabase(conn) as db: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2509: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s __ test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_conn] ___ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s integer = 'UInt64' 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 1431s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2506: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _________________ test_database_uri_string[mysql_pymysql_conn] _________________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s test_frame1 = index A B C D 1431s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1431s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1431s 1431s @pytest.mark.parametrize("conn", all_connectable) 1431s def test_database_uri_string(conn, request, test_frame1): 1431s td.versioned_importorskip("sqlalchemy") 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2519: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ______________ test_database_uri_string[postgresql_psycopg2_conn] ______________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s test_frame1 = index A B C D 1431s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1431s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1431s 1431s @pytest.mark.parametrize("conn", all_connectable) 1431s def test_database_uri_string(conn, request, test_frame1): 1431s td.versioned_importorskip("sqlalchemy") 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2519: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _________ test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_conn] _________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s 1431s @td.skip_if_installed("pg8000") 1431s @pytest.mark.parametrize("conn", all_connectable) 1431s def test_pg8000_sqlalchemy_passthrough_error(conn, request): 1431s td.versioned_importorskip("sqlalchemy") 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2541: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ______ test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_conn] ______ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s 1431s @td.skip_if_installed("pg8000") 1431s @pytest.mark.parametrize("conn", all_connectable) 1431s def test_pg8000_sqlalchemy_passthrough_error(conn, request): 1431s td.versioned_importorskip("sqlalchemy") 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2541: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ______________ test_query_by_text_obj[mysql_pymysql_engine_iris] _______________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_engine_iris' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1431s def test_query_by_text_obj(conn, request): 1431s # WIP : GH10846 1431s conn_name = conn 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2553: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1431s create_and_load_iris(mysql_pymysql_engine, iris_path) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1431s with conn.begin() as con: 1431s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1431s return next(self.gen) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1431s with self.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s _______________ test_query_by_text_obj[mysql_pymysql_conn_iris] ________________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn_iris' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1431s def test_query_by_text_obj(conn, request): 1431s # WIP : GH10846 1431s conn_name = conn 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2553: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1431s fixturedef = request._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1431s create_and_load_iris(mysql_pymysql_engine, iris_path) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1431s with conn.begin() as con: 1431s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1431s return next(self.gen) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1431s with self.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ___________ test_query_by_text_obj[postgresql_psycopg2_engine_iris] ____________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_engine_iris' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1431s def test_query_by_text_obj(conn, request): 1431s # WIP : GH10846 1431s conn_name = conn 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2553: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1431s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1431s with conn.begin() as con: 1431s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1431s return next(self.gen) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1431s with self.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ____________ test_query_by_text_obj[postgresql_psycopg2_conn_iris] _____________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn_iris' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1431s def test_query_by_text_obj(conn, request): 1431s # WIP : GH10846 1431s conn_name = conn 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2553: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1431s fixturedef = request._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1431s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1431s with conn.begin() as con: 1431s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1431s return next(self.gen) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1431s with self.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _____________ test_query_by_select_obj[mysql_pymysql_engine_iris] ______________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_engine_iris' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1431s def test_query_by_select_obj(conn, request): 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2567: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1431s create_and_load_iris(mysql_pymysql_engine, iris_path) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1431s with conn.begin() as con: 1431s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1431s return next(self.gen) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1431s with self.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ______________ test_query_by_select_obj[mysql_pymysql_conn_iris] _______________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn_iris' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1431s def test_query_by_select_obj(conn, request): 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2567: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1431s fixturedef = request._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1431s create_and_load_iris(mysql_pymysql_engine, iris_path) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1431s with conn.begin() as con: 1431s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1431s return next(self.gen) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1431s with self.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s __________ test_query_by_select_obj[postgresql_psycopg2_engine_iris] ___________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_engine_iris' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1431s def test_query_by_select_obj(conn, request): 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2567: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1431s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1431s with conn.begin() as con: 1431s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1431s return next(self.gen) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1431s with self.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ___________ test_query_by_select_obj[postgresql_psycopg2_conn_iris] ____________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn_iris' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1431s def test_query_by_select_obj(conn, request): 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2567: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1431s fixturedef = request._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1431s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1431s with conn.begin() as con: 1431s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1431s return next(self.gen) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1431s with self.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ______________ test_column_with_percentage[mysql_pymysql_engine] _______________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", all_connectable) 1431s def test_column_with_percentage(conn, request): 1431s # GH 37157 1431s conn_name = conn 1431s if conn_name == "sqlite_buildin": 1431s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1431s 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame({"A": [0, 1, 2], "%_variation": [3, 4, 5]}) 1431s > df.to_sql(name="test_column_percentage", con=conn, index=False) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2590: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1431s return func(*args, **kwargs) 1431s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1431s return sql.to_sql( 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1431s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1431s return SQLDatabase(con, schema, need_transaction) 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s _______________ test_column_with_percentage[mysql_pymysql_conn] ________________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", all_connectable) 1431s def test_column_with_percentage(conn, request): 1431s # GH 37157 1431s conn_name = conn 1431s if conn_name == "sqlite_buildin": 1431s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1431s 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2588: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ___________ test_column_with_percentage[postgresql_psycopg2_engine] ____________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", all_connectable) 1431s def test_column_with_percentage(conn, request): 1431s # GH 37157 1431s conn_name = conn 1431s if conn_name == "sqlite_buildin": 1431s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1431s 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame({"A": [0, 1, 2], "%_variation": [3, 4, 5]}) 1431s > df.to_sql(name="test_column_percentage", con=conn, index=False) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2590: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1431s return func(*args, **kwargs) 1431s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1431s return sql.to_sql( 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1431s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1431s return SQLDatabase(con, schema, need_transaction) 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ____________ test_column_with_percentage[postgresql_psycopg2_conn] _____________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", all_connectable) 1431s def test_column_with_percentage(conn, request): 1431s # GH 37157 1431s conn_name = conn 1431s if conn_name == "sqlite_buildin": 1431s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1431s 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2588: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ___________________ test_create_table[mysql_pymysql_engine] ____________________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_create_table(conn, request): 1431s if conn == "sqlite_str": 1431s pytest.skip("sqlite_str has no inspection system") 1431s 1431s conn = request.getfixturevalue(conn) 1431s 1431s from sqlalchemy import inspect 1431s 1431s temp_frame = DataFrame({"one": [1.0, 2.0, 3.0, 4.0], "two": [4.0, 3.0, 2.0, 1.0]}) 1431s > with sql.SQLDatabase(conn, need_transaction=True) as pandasSQL: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2681: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ____________________ test_create_table[mysql_pymysql_conn] _____________________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_create_table(conn, request): 1431s if conn == "sqlite_str": 1431s pytest.skip("sqlite_str has no inspection system") 1431s 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2676: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ________________ test_create_table[postgresql_psycopg2_engine] _________________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_create_table(conn, request): 1431s if conn == "sqlite_str": 1431s pytest.skip("sqlite_str has no inspection system") 1431s 1431s conn = request.getfixturevalue(conn) 1431s 1431s from sqlalchemy import inspect 1431s 1431s temp_frame = DataFrame({"one": [1.0, 2.0, 3.0, 4.0], "two": [4.0, 3.0, 2.0, 1.0]}) 1431s > with sql.SQLDatabase(conn, need_transaction=True) as pandasSQL: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2681: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _________________ test_create_table[postgresql_psycopg2_conn] __________________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_create_table(conn, request): 1431s if conn == "sqlite_str": 1431s pytest.skip("sqlite_str has no inspection system") 1431s 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2676: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ____________________ test_drop_table[mysql_pymysql_engine] _____________________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_drop_table(conn, request): 1431s if conn == "sqlite_str": 1431s pytest.skip("sqlite_str has no inspection system") 1431s 1431s conn = request.getfixturevalue(conn) 1431s 1431s from sqlalchemy import inspect 1431s 1431s temp_frame = DataFrame({"one": [1.0, 2.0, 3.0, 4.0], "two": [4.0, 3.0, 2.0, 1.0]}) 1431s > with sql.SQLDatabase(conn) as pandasSQL: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2702: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s _____________________ test_drop_table[mysql_pymysql_conn] ______________________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_drop_table(conn, request): 1431s if conn == "sqlite_str": 1431s pytest.skip("sqlite_str has no inspection system") 1431s 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2697: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s _________________ test_drop_table[postgresql_psycopg2_engine] __________________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_drop_table(conn, request): 1431s if conn == "sqlite_str": 1431s pytest.skip("sqlite_str has no inspection system") 1431s 1431s conn = request.getfixturevalue(conn) 1431s 1431s from sqlalchemy import inspect 1431s 1431s temp_frame = DataFrame({"one": [1.0, 2.0, 3.0, 4.0], "two": [4.0, 3.0, 2.0, 1.0]}) 1431s > with sql.SQLDatabase(conn) as pandasSQL: 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2702: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s __________________ test_drop_table[postgresql_psycopg2_conn] ___________________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_drop_table(conn, request): 1431s if conn == "sqlite_str": 1431s pytest.skip("sqlite_str has no inspection system") 1431s 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2697: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _____________________ test_roundtrip[mysql_pymysql_engine] _____________________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s test_frame1 = index A B C D 1431s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1431s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1431s 1431s @pytest.mark.parametrize("conn", all_connectable) 1431s def test_roundtrip(conn, request, test_frame1): 1431s if conn == "sqlite_str": 1431s pytest.skip("sqlite_str has no inspection system") 1431s 1431s conn_name = conn 1431s conn = request.getfixturevalue(conn) 1431s > pandasSQL = pandasSQL_builder(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2725: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1431s return SQLDatabase(con, schema, need_transaction) 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ______________________ test_roundtrip[mysql_pymysql_conn] ______________________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s test_frame1 = index A B C D 1431s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1431s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1431s 1431s @pytest.mark.parametrize("conn", all_connectable) 1431s def test_roundtrip(conn, request, test_frame1): 1431s if conn == "sqlite_str": 1431s pytest.skip("sqlite_str has no inspection system") 1431s 1431s conn_name = conn 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2724: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s __________________ test_roundtrip[postgresql_psycopg2_engine] __________________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s test_frame1 = index A B C D 1431s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1431s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1431s 1431s @pytest.mark.parametrize("conn", all_connectable) 1431s def test_roundtrip(conn, request, test_frame1): 1431s if conn == "sqlite_str": 1431s pytest.skip("sqlite_str has no inspection system") 1431s 1431s conn_name = conn 1431s conn = request.getfixturevalue(conn) 1431s > pandasSQL = pandasSQL_builder(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2725: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1431s return SQLDatabase(con, schema, need_transaction) 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ___________________ test_roundtrip[postgresql_psycopg2_conn] ___________________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s test_frame1 = index A B C D 1431s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1431s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1431s 1431s @pytest.mark.parametrize("conn", all_connectable) 1431s def test_roundtrip(conn, request, test_frame1): 1431s if conn == "sqlite_str": 1431s pytest.skip("sqlite_str has no inspection system") 1431s 1431s conn_name = conn 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2724: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _________________ test_execute_sql[mysql_pymysql_engine_iris] __________________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_engine_iris' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", all_connectable_iris) 1431s def test_execute_sql(conn, request): 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2742: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1431s create_and_load_iris(mysql_pymysql_engine, iris_path) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1431s with conn.begin() as con: 1431s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1431s return next(self.gen) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1431s with self.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s __________________ test_execute_sql[mysql_pymysql_conn_iris] ___________________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn_iris' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", all_connectable_iris) 1431s def test_execute_sql(conn, request): 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2742: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1431s fixturedef = request._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1431s create_and_load_iris(mysql_pymysql_engine, iris_path) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1431s with conn.begin() as con: 1431s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1431s return next(self.gen) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1431s with self.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ______________ test_execute_sql[postgresql_psycopg2_engine_iris] _______________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_engine_iris' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", all_connectable_iris) 1431s def test_execute_sql(conn, request): 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2742: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1431s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1431s with conn.begin() as con: 1431s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1431s return next(self.gen) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1431s with self.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _______________ test_execute_sql[postgresql_psycopg2_conn_iris] ________________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn_iris' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", all_connectable_iris) 1431s def test_execute_sql(conn, request): 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2742: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1431s fixturedef = request._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1431s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1431s with conn.begin() as con: 1431s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1431s return next(self.gen) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1431s with self.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ____________ test_sqlalchemy_read_table[mysql_pymysql_engine_iris] _____________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_engine_iris' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1431s def test_sqlalchemy_read_table(conn, request): 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2753: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1431s create_and_load_iris(mysql_pymysql_engine, iris_path) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1431s with conn.begin() as con: 1431s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1431s return next(self.gen) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1431s with self.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s _____________ test_sqlalchemy_read_table[mysql_pymysql_conn_iris] ______________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn_iris' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1431s def test_sqlalchemy_read_table(conn, request): 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2753: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1431s fixturedef = request._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1431s create_and_load_iris(mysql_pymysql_engine, iris_path) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1431s with conn.begin() as con: 1431s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1431s return next(self.gen) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1431s with self.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s _________ test_sqlalchemy_read_table[postgresql_psycopg2_engine_iris] __________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_engine_iris' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1431s def test_sqlalchemy_read_table(conn, request): 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2753: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1431s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1431s with conn.begin() as con: 1431s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1431s return next(self.gen) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1431s with self.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s __________ test_sqlalchemy_read_table[postgresql_psycopg2_conn_iris] ___________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn_iris' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1431s def test_sqlalchemy_read_table(conn, request): 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2753: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1431s fixturedef = request._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1431s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1431s with conn.begin() as con: 1431s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1431s return next(self.gen) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1431s with self.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ________ test_sqlalchemy_read_table_columns[mysql_pymysql_engine_iris] _________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_engine_iris' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1431s def test_sqlalchemy_read_table_columns(conn, request): 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2760: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1431s create_and_load_iris(mysql_pymysql_engine, iris_path) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1431s with conn.begin() as con: 1431s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1431s return next(self.gen) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1431s with self.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s _________ test_sqlalchemy_read_table_columns[mysql_pymysql_conn_iris] __________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn_iris' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1431s def test_sqlalchemy_read_table_columns(conn, request): 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2760: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1431s fixturedef = request._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1431s create_and_load_iris(mysql_pymysql_engine, iris_path) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1431s with conn.begin() as con: 1431s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1431s return next(self.gen) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1431s with self.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s _____ test_sqlalchemy_read_table_columns[postgresql_psycopg2_engine_iris] ______ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_engine_iris' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1431s def test_sqlalchemy_read_table_columns(conn, request): 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2760: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1431s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1431s with conn.begin() as con: 1431s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1431s return next(self.gen) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1431s with self.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ______ test_sqlalchemy_read_table_columns[postgresql_psycopg2_conn_iris] _______ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn_iris' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1431s def test_sqlalchemy_read_table_columns(conn, request): 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2760: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1431s fixturedef = request._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1431s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1431s with conn.begin() as con: 1431s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1431s return next(self.gen) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1431s with self.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ___________ test_read_table_absent_raises[mysql_pymysql_engine_iris] ___________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_engine_iris' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1431s def test_read_table_absent_raises(conn, request): 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2769: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1431s create_and_load_iris(mysql_pymysql_engine, iris_path) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1431s with conn.begin() as con: 1431s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1431s return next(self.gen) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1431s with self.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ____________ test_read_table_absent_raises[mysql_pymysql_conn_iris] ____________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn_iris' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1431s def test_read_table_absent_raises(conn, request): 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2769: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1431s fixturedef = request._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1431s create_and_load_iris(mysql_pymysql_engine, iris_path) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1431s with conn.begin() as con: 1431s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1431s return next(self.gen) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1431s with self.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ________ test_read_table_absent_raises[postgresql_psycopg2_engine_iris] ________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_engine_iris' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1431s def test_read_table_absent_raises(conn, request): 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2769: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1431s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1431s with conn.begin() as con: 1431s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1431s return next(self.gen) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1431s with self.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _________ test_read_table_absent_raises[postgresql_psycopg2_conn_iris] _________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn_iris' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1431s def test_read_table_absent_raises(conn, request): 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2769: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1431s fixturedef = request._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1431s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1431s with conn.begin() as con: 1431s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1431s return next(self.gen) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1431s with self.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s __ test_sqlalchemy_default_type_conversion[postgresql_psycopg2_engine_types] ___ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_engine_types' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 1431s def test_sqlalchemy_default_type_conversion(conn, request): 1431s conn_name = conn 1431s if conn_name == "sqlite_str": 1431s pytest.skip("types tables not created in sqlite_str fixture") 1431s elif "mysql" in conn_name or "sqlite" in conn_name: 1431s request.applymarker( 1431s pytest.mark.xfail(reason="boolean dtype not inferred properly") 1431s ) 1431s 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2785: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1431s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1431s with conn.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ___ test_sqlalchemy_default_type_conversion[postgresql_psycopg2_conn_types] ____ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn_types' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 1431s def test_sqlalchemy_default_type_conversion(conn, request): 1431s conn_name = conn 1431s if conn_name == "sqlite_str": 1431s pytest.skip("types tables not created in sqlite_str fixture") 1431s elif "mysql" in conn_name or "sqlite" in conn_name: 1431s request.applymarker( 1431s pytest.mark.xfail(reason="boolean dtype not inferred properly") 1431s ) 1431s 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2785: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1431s fixturedef = request._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1431s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1431s with conn.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ______________________ test_bigint[mysql_pymysql_engine] _______________________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_bigint(conn, request): 1431s # int64 should be converted to BigInteger, GH7433 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame(data={"i64": [2**62]}) 1431s > assert df.to_sql(name="test_bigint", con=conn, index=False) == 1 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2803: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1431s return func(*args, **kwargs) 1431s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1431s return sql.to_sql( 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1431s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1431s return SQLDatabase(con, schema, need_transaction) 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s _______________________ test_bigint[mysql_pymysql_conn] ________________________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_bigint(conn, request): 1431s # int64 should be converted to BigInteger, GH7433 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2801: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ___________________ test_bigint[postgresql_psycopg2_engine] ____________________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_bigint(conn, request): 1431s # int64 should be converted to BigInteger, GH7433 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame(data={"i64": [2**62]}) 1431s > assert df.to_sql(name="test_bigint", con=conn, index=False) == 1 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2803: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1431s return func(*args, **kwargs) 1431s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1431s return sql.to_sql( 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1431s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1431s return SQLDatabase(con, schema, need_transaction) 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ____________________ test_bigint[postgresql_psycopg2_conn] _____________________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_bigint(conn, request): 1431s # int64 should be converted to BigInteger, GH7433 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2801: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ______________ test_default_date_load[mysql_pymysql_engine_types] ______________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_engine_types' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 1431s def test_default_date_load(conn, request): 1431s conn_name = conn 1431s if conn_name == "sqlite_str": 1431s pytest.skip("types tables not created in sqlite_str fixture") 1431s elif "sqlite" in conn_name: 1431s request.applymarker( 1431s pytest.mark.xfail(reason="sqlite does not read date properly") 1431s ) 1431s 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2819: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1431s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1431s with conn.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s _______________ test_default_date_load[mysql_pymysql_conn_types] _______________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn_types' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 1431s def test_default_date_load(conn, request): 1431s conn_name = conn 1431s if conn_name == "sqlite_str": 1431s pytest.skip("types tables not created in sqlite_str fixture") 1431s elif "sqlite" in conn_name: 1431s request.applymarker( 1431s pytest.mark.xfail(reason="sqlite does not read date properly") 1431s ) 1431s 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2819: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1431s fixturedef = request._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1431s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1431s with conn.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ___________ test_default_date_load[postgresql_psycopg2_engine_types] ___________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_engine_types' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 1431s def test_default_date_load(conn, request): 1431s conn_name = conn 1431s if conn_name == "sqlite_str": 1431s pytest.skip("types tables not created in sqlite_str fixture") 1431s elif "sqlite" in conn_name: 1431s request.applymarker( 1431s pytest.mark.xfail(reason="sqlite does not read date properly") 1431s ) 1431s 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2819: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1431s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1431s with conn.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ____________ test_default_date_load[postgresql_psycopg2_conn_types] ____________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn_types' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 1431s def test_default_date_load(conn, request): 1431s conn_name = conn 1431s if conn_name == "sqlite_str": 1431s pytest.skip("types tables not created in sqlite_str fixture") 1431s elif "sqlite" in conn_name: 1431s request.applymarker( 1431s pytest.mark.xfail(reason="sqlite does not read date properly") 1431s ) 1431s 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2819: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1431s fixturedef = request._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1431s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1431s with conn.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ______ test_datetime_with_timezone_query[None-postgresql_psycopg2_engine] ______ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s parse_dates = None 1431s 1431s @pytest.mark.parametrize("conn", postgresql_connectable) 1431s @pytest.mark.parametrize("parse_dates", [None, ["DateColWithTz"]]) 1431s def test_datetime_with_timezone_query(conn, request, parse_dates): 1431s # edge case that converts postgresql datetime with time zone types 1431s # to datetime64[ns,psycopg2.tz.FixedOffsetTimezone..], which is ok 1431s # but should be more natural, so coerce to datetime64[ns] for now 1431s conn = request.getfixturevalue(conn) 1431s > expected = create_and_load_postgres_datetz(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2832: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:351: in create_and_load_postgres_datetz 1431s with conn.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _______ test_datetime_with_timezone_query[None-postgresql_psycopg2_conn] _______ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s parse_dates = None 1431s 1431s @pytest.mark.parametrize("conn", postgresql_connectable) 1431s @pytest.mark.parametrize("parse_dates", [None, ["DateColWithTz"]]) 1431s def test_datetime_with_timezone_query(conn, request, parse_dates): 1431s # edge case that converts postgresql datetime with time zone types 1431s # to datetime64[ns,psycopg2.tz.FixedOffsetTimezone..], which is ok 1431s # but should be more natural, so coerce to datetime64[ns] for now 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2831: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s __ test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_engine] __ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s parse_dates = ['DateColWithTz'] 1431s 1431s @pytest.mark.parametrize("conn", postgresql_connectable) 1431s @pytest.mark.parametrize("parse_dates", [None, ["DateColWithTz"]]) 1431s def test_datetime_with_timezone_query(conn, request, parse_dates): 1431s # edge case that converts postgresql datetime with time zone types 1431s # to datetime64[ns,psycopg2.tz.FixedOffsetTimezone..], which is ok 1431s # but should be more natural, so coerce to datetime64[ns] for now 1431s conn = request.getfixturevalue(conn) 1431s > expected = create_and_load_postgres_datetz(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2832: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:351: in create_and_load_postgres_datetz 1431s with conn.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ___ test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_conn] ___ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s parse_dates = ['DateColWithTz'] 1431s 1431s @pytest.mark.parametrize("conn", postgresql_connectable) 1431s @pytest.mark.parametrize("parse_dates", [None, ["DateColWithTz"]]) 1431s def test_datetime_with_timezone_query(conn, request, parse_dates): 1431s # edge case that converts postgresql datetime with time zone types 1431s # to datetime64[ns,psycopg2.tz.FixedOffsetTimezone..], which is ok 1431s # but should be more natural, so coerce to datetime64[ns] for now 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2831: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ___ test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_engine] ____ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", postgresql_connectable) 1431s def test_datetime_with_timezone_query_chunksize(conn, request): 1431s conn = request.getfixturevalue(conn) 1431s > expected = create_and_load_postgres_datetz(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2843: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:351: in create_and_load_postgres_datetz 1431s with conn.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ____ test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_conn] _____ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", postgresql_connectable) 1431s def test_datetime_with_timezone_query_chunksize(conn, request): 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2842: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ________ test_datetime_with_timezone_table[postgresql_psycopg2_engine] _________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", postgresql_connectable) 1431s def test_datetime_with_timezone_table(conn, request): 1431s conn = request.getfixturevalue(conn) 1431s > expected = create_and_load_postgres_datetz(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2856: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:351: in create_and_load_postgres_datetz 1431s with conn.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _________ test_datetime_with_timezone_table[postgresql_psycopg2_conn] __________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", postgresql_connectable) 1431s def test_datetime_with_timezone_table(conn, request): 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2855: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _________ test_datetime_with_timezone_roundtrip[mysql_pymysql_engine] __________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_datetime_with_timezone_roundtrip(conn, request): 1431s conn_name = conn 1431s conn = request.getfixturevalue(conn) 1431s # GH 9086 1431s # Write datetimetz data to a db and read it back 1431s # For dbs that support timestamps with timezones, should get back UTC 1431s # otherwise naive data should be returned 1431s expected = DataFrame( 1431s {"A": date_range("2013-01-01 09:00:00", periods=3, tz="US/Pacific")} 1431s ) 1431s > assert expected.to_sql(name="test_datetime_tz", con=conn, index=False) == 3 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2872: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1431s return func(*args, **kwargs) 1431s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1431s return sql.to_sql( 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1431s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1431s return SQLDatabase(con, schema, need_transaction) 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s __________ test_datetime_with_timezone_roundtrip[mysql_pymysql_conn] ___________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_datetime_with_timezone_roundtrip(conn, request): 1431s conn_name = conn 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2864: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ______ test_datetime_with_timezone_roundtrip[postgresql_psycopg2_engine] _______ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_datetime_with_timezone_roundtrip(conn, request): 1431s conn_name = conn 1431s conn = request.getfixturevalue(conn) 1431s # GH 9086 1431s # Write datetimetz data to a db and read it back 1431s # For dbs that support timestamps with timezones, should get back UTC 1431s # otherwise naive data should be returned 1431s expected = DataFrame( 1431s {"A": date_range("2013-01-01 09:00:00", periods=3, tz="US/Pacific")} 1431s ) 1431s > assert expected.to_sql(name="test_datetime_tz", con=conn, index=False) == 3 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2872: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1431s return func(*args, **kwargs) 1431s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1431s return sql.to_sql( 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1431s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1431s return SQLDatabase(con, schema, need_transaction) 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _______ test_datetime_with_timezone_roundtrip[postgresql_psycopg2_conn] ________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_datetime_with_timezone_roundtrip(conn, request): 1431s conn_name = conn 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2864: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ______________ test_out_of_bounds_datetime[mysql_pymysql_engine] _______________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_out_of_bounds_datetime(conn, request): 1431s # GH 26761 1431s conn = request.getfixturevalue(conn) 1431s data = DataFrame({"date": datetime(9999, 1, 1)}, index=[0]) 1431s > assert data.to_sql(name="test_datetime_obb", con=conn, index=False) == 1 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2897: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1431s return func(*args, **kwargs) 1431s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1431s return sql.to_sql( 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1431s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1431s return SQLDatabase(con, schema, need_transaction) 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s _______________ test_out_of_bounds_datetime[mysql_pymysql_conn] ________________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_out_of_bounds_datetime(conn, request): 1431s # GH 26761 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2895: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ___________ test_out_of_bounds_datetime[postgresql_psycopg2_engine] ____________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_out_of_bounds_datetime(conn, request): 1431s # GH 26761 1431s conn = request.getfixturevalue(conn) 1431s data = DataFrame({"date": datetime(9999, 1, 1)}, index=[0]) 1431s > assert data.to_sql(name="test_datetime_obb", con=conn, index=False) == 1 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2897: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1431s return func(*args, **kwargs) 1431s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1431s return sql.to_sql( 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1431s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1431s return SQLDatabase(con, schema, need_transaction) 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ____________ test_out_of_bounds_datetime[postgresql_psycopg2_conn] _____________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_out_of_bounds_datetime(conn, request): 1431s # GH 26761 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2895: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ___________ test_naive_datetimeindex_roundtrip[mysql_pymysql_engine] ___________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_naive_datetimeindex_roundtrip(conn, request): 1431s # GH 23510 1431s # Ensure that a naive DatetimeIndex isn't converted to UTC 1431s conn = request.getfixturevalue(conn) 1431s dates = date_range("2018-01-01", periods=5, freq="6h")._with_freq(None) 1431s expected = DataFrame({"nums": range(5)}, index=dates) 1431s > assert expected.to_sql(name="foo_table", con=conn, index_label="info_date") == 5 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2910: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1431s return func(*args, **kwargs) 1431s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1431s return sql.to_sql( 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1431s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1431s return SQLDatabase(con, schema, need_transaction) 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ____________ test_naive_datetimeindex_roundtrip[mysql_pymysql_conn] ____________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_naive_datetimeindex_roundtrip(conn, request): 1431s # GH 23510 1431s # Ensure that a naive DatetimeIndex isn't converted to UTC 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2907: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ________ test_naive_datetimeindex_roundtrip[postgresql_psycopg2_engine] ________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_naive_datetimeindex_roundtrip(conn, request): 1431s # GH 23510 1431s # Ensure that a naive DatetimeIndex isn't converted to UTC 1431s conn = request.getfixturevalue(conn) 1431s dates = date_range("2018-01-01", periods=5, freq="6h")._with_freq(None) 1431s expected = DataFrame({"nums": range(5)}, index=dates) 1431s > assert expected.to_sql(name="foo_table", con=conn, index_label="info_date") == 5 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2910: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1431s return func(*args, **kwargs) 1431s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1431s return sql.to_sql( 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1431s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1431s return SQLDatabase(con, schema, need_transaction) 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _________ test_naive_datetimeindex_roundtrip[postgresql_psycopg2_conn] _________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_naive_datetimeindex_roundtrip(conn, request): 1431s # GH 23510 1431s # Ensure that a naive DatetimeIndex isn't converted to UTC 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2907: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ________________ test_date_parsing[mysql_pymysql_engine_types] _________________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_engine_types' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 1431s def test_date_parsing(conn, request): 1431s # No Parsing 1431s conn_name = conn 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2920: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1431s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1431s with conn.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s _________________ test_date_parsing[mysql_pymysql_conn_types] __________________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn_types' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 1431s def test_date_parsing(conn, request): 1431s # No Parsing 1431s conn_name = conn 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2920: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1431s fixturedef = request._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1431s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1431s with conn.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s _____________ test_date_parsing[postgresql_psycopg2_engine_types] ______________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_engine_types' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 1431s def test_date_parsing(conn, request): 1431s # No Parsing 1431s conn_name = conn 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2920: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1431s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1431s with conn.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ______________ test_date_parsing[postgresql_psycopg2_conn_types] _______________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn_types' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 1431s def test_date_parsing(conn, request): 1431s # No Parsing 1431s conn_name = conn 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2920: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1431s fixturedef = request._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1431s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1431s with conn.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _____________________ test_datetime[mysql_pymysql_engine] ______________________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_datetime(conn, request): 1431s conn_name = conn 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame( 1431s {"A": date_range("2013-01-01 09:00:00", periods=3), "B": np.arange(3.0)} 1431s ) 1431s > assert df.to_sql(name="test_datetime", con=conn) == 3 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2955: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1431s return func(*args, **kwargs) 1431s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1431s return sql.to_sql( 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1431s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1431s return SQLDatabase(con, schema, need_transaction) 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ______________________ test_datetime[mysql_pymysql_conn] _______________________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_datetime(conn, request): 1431s conn_name = conn 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2951: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s __________________ test_datetime[postgresql_psycopg2_engine] ___________________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_datetime(conn, request): 1431s conn_name = conn 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame( 1431s {"A": date_range("2013-01-01 09:00:00", periods=3), "B": np.arange(3.0)} 1431s ) 1431s > assert df.to_sql(name="test_datetime", con=conn) == 3 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2955: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1431s return func(*args, **kwargs) 1431s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1431s return sql.to_sql( 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1431s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1431s return SQLDatabase(con, schema, need_transaction) 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ___________________ test_datetime[postgresql_psycopg2_conn] ____________________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_datetime(conn, request): 1431s conn_name = conn 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2951: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ___________________ test_datetime_NaT[mysql_pymysql_engine] ____________________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_datetime_NaT(conn, request): 1431s conn_name = conn 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame( 1431s {"A": date_range("2013-01-01 09:00:00", periods=3), "B": np.arange(3.0)} 1431s ) 1431s df.loc[1, "A"] = np.nan 1431s > assert df.to_sql(name="test_datetime", con=conn, index=False) == 3 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2981: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1431s return func(*args, **kwargs) 1431s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1431s return sql.to_sql( 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1431s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1431s return SQLDatabase(con, schema, need_transaction) 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ____________________ test_datetime_NaT[mysql_pymysql_conn] _____________________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_datetime_NaT(conn, request): 1431s conn_name = conn 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2976: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ________________ test_datetime_NaT[postgresql_psycopg2_engine] _________________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_datetime_NaT(conn, request): 1431s conn_name = conn 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame( 1431s {"A": date_range("2013-01-01 09:00:00", periods=3), "B": np.arange(3.0)} 1431s ) 1431s df.loc[1, "A"] = np.nan 1431s > assert df.to_sql(name="test_datetime", con=conn, index=False) == 3 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2981: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1431s return func(*args, **kwargs) 1431s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1431s return sql.to_sql( 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1431s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1431s return SQLDatabase(con, schema, need_transaction) 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _________________ test_datetime_NaT[postgresql_psycopg2_conn] __________________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_datetime_NaT(conn, request): 1431s conn_name = conn 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2976: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ___________________ test_datetime_date[mysql_pymysql_engine] ___________________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_datetime_date(conn, request): 1431s # test support for datetime.date 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([date(2014, 1, 1), date(2014, 1, 2)], columns=["a"]) 1431s > assert df.to_sql(name="test_date", con=conn, index=False) == 2 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3002: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1431s return func(*args, **kwargs) 1431s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1431s return sql.to_sql( 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1431s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1431s return SQLDatabase(con, schema, need_transaction) 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ____________________ test_datetime_date[mysql_pymysql_conn] ____________________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_datetime_date(conn, request): 1431s # test support for datetime.date 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3000: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ________________ test_datetime_date[postgresql_psycopg2_engine] ________________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_datetime_date(conn, request): 1431s # test support for datetime.date 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([date(2014, 1, 1), date(2014, 1, 2)], columns=["a"]) 1431s > assert df.to_sql(name="test_date", con=conn, index=False) == 2 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3002: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1431s return func(*args, **kwargs) 1431s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1431s return sql.to_sql( 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1431s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1431s return SQLDatabase(con, schema, need_transaction) 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _________________ test_datetime_date[postgresql_psycopg2_conn] _________________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_datetime_date(conn, request): 1431s # test support for datetime.date 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3000: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ___________________ test_datetime_time[mysql_pymysql_engine] ___________________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s sqlite_buildin = 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_datetime_time(conn, request, sqlite_buildin): 1431s # test support for datetime.time 1431s conn_name = conn 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([time(9, 0, 0), time(9, 1, 30)], columns=["a"]) 1431s > assert df.to_sql(name="test_time", con=conn, index=False) == 2 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3016: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1431s return func(*args, **kwargs) 1431s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1431s return sql.to_sql( 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1431s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1431s return SQLDatabase(con, schema, need_transaction) 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ____________________ test_datetime_time[mysql_pymysql_conn] ____________________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s sqlite_buildin = 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_datetime_time(conn, request, sqlite_buildin): 1431s # test support for datetime.time 1431s conn_name = conn 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3014: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s ________________ test_datetime_time[postgresql_psycopg2_engine] ________________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s sqlite_buildin = 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_datetime_time(conn, request, sqlite_buildin): 1431s # test support for datetime.time 1431s conn_name = conn 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame([time(9, 0, 0), time(9, 1, 30)], columns=["a"]) 1431s > assert df.to_sql(name="test_time", con=conn, index=False) == 2 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3016: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1431s return func(*args, **kwargs) 1431s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1431s return sql.to_sql( 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1431s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1431s return SQLDatabase(con, schema, need_transaction) 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s _________________ test_datetime_time[postgresql_psycopg2_conn] _________________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s sqlite_buildin = 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_datetime_time(conn, request, sqlite_buildin): 1431s # test support for datetime.time 1431s conn_name = conn 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3014: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ________________ test_mixed_dtype_insert[mysql_pymysql_engine] _________________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_mixed_dtype_insert(conn, request): 1431s # see GH6509 1431s conn = request.getfixturevalue(conn) 1431s s1 = Series(2**25 + 1, dtype=np.int32) 1431s s2 = Series(0.0, dtype=np.float32) 1431s df = DataFrame({"s1": s1, "s2": s2}) 1431s 1431s # write and read again 1431s > assert df.to_sql(name="test_read_write", con=conn, index=False) == 1 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3046: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1431s return func(*args, **kwargs) 1431s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1431s return sql.to_sql( 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1431s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1431s return SQLDatabase(con, schema, need_transaction) 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s _________________ test_mixed_dtype_insert[mysql_pymysql_conn] __________________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'mysql_pymysql_conn' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_mixed_dtype_insert(conn, request): 1431s # see GH6509 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3040: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1431s with mysql_pymysql_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s _____________ test_mixed_dtype_insert[postgresql_psycopg2_engine] ______________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_mixed_dtype_insert(conn, request): 1431s # see GH6509 1431s conn = request.getfixturevalue(conn) 1431s s1 = Series(2**25 + 1, dtype=np.int32) 1431s s2 = Series(0.0, dtype=np.float32) 1431s df = DataFrame({"s1": s1, "s2": s2}) 1431s 1431s # write and read again 1431s > assert df.to_sql(name="test_read_write", con=conn, index=False) == 1 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3046: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1431s return func(*args, **kwargs) 1431s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1431s return sql.to_sql( 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1431s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1431s return SQLDatabase(con, schema, need_transaction) 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ______________ test_mixed_dtype_insert[postgresql_psycopg2_conn] _______________ 1431s self = 1431s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1431s connection = None, _has_events = None, _allow_revalidate = True 1431s _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = 'postgresql_psycopg2_conn' 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_mixed_dtype_insert(conn, request): 1431s # see GH6509 1431s > conn = request.getfixturevalue(conn) 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3040: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1431s fixturedef = self._get_active_fixturedef(argname) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1431s fixturedef.execute(request=subrequest) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1431s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1431s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1431s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1431s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1431s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1431s return (yield) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1431s result = call_fixture_func(fixturefunc, request, kwargs) 1431s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1431s fixture_result = next(generator) 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1431s with postgresql_psycopg2_engine.connect() as conn: 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1431s connection_factory = None, cursor_factory = None 1431s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1431s kwasync = {} 1431s 1431s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1431s """ 1431s Create a new database connection. 1431s 1431s The connection parameters can be specified as a string: 1431s 1431s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1431s 1431s or using a set of keyword arguments: 1431s 1431s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1431s 1431s Or as a mix of both. The basic connection parameters are: 1431s 1431s - *dbname*: the database name 1431s - *database*: the database name (only as keyword argument) 1431s - *user*: user name used to authenticate 1431s - *password*: password used to authenticate 1431s - *host*: database host address (defaults to UNIX socket if not provided) 1431s - *port*: connection port number (defaults to 5432 if not provided) 1431s 1431s Using the *connection_factory* parameter a different class or connections 1431s factory can be specified. It should be a callable object taking a dsn 1431s argument. 1431s 1431s Using the *cursor_factory* parameter, a new default cursor factory will be 1431s used by cursor(). 1431s 1431s Using *async*=True an asynchronous connection will be created. *async_* is 1431s a valid alias (for Python versions where ``async`` is a keyword). 1431s 1431s Any other keyword parameter will be passed to the underlying client 1431s library: the list of supported parameters depends on the library version. 1431s 1431s """ 1431s kwasync = {} 1431s if 'async' in kwargs: 1431s kwasync['async'] = kwargs.pop('async') 1431s if 'async_' in kwargs: 1431s kwasync['async_'] = kwargs.pop('async_') 1431s 1431s dsn = _ext.make_dsn(dsn, **kwargs) 1431s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1431s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1431s E Is the server running on that host and accepting TCP/IP connections? 1431s E 1431s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1431s 1431s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1431s ____________________ test_nan_numeric[mysql_pymysql_engine] ____________________ 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s > sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3.13/socket.py:864: in create_connection 1431s raise exceptions[0] 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s address = ('localhost', 3306), timeout = 10, source_address = None 1431s 1431s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1431s source_address=None, *, all_errors=False): 1431s """Connect to *address* and return the socket object. 1431s 1431s Convenience function. Connect to *address* (a 2-tuple ``(host, 1431s port)``) and return the socket object. Passing the optional 1431s *timeout* parameter will set the timeout on the socket instance 1431s before attempting to connect. If no *timeout* is supplied, the 1431s global default timeout setting returned by :func:`getdefaulttimeout` 1431s is used. If *source_address* is set it must be a tuple of (host, port) 1431s for the socket to bind as a source address before making the connection. 1431s A host of '' or port 0 tells the OS to use the default. When a connection 1431s cannot be created, raises the last error if *all_errors* is False, 1431s and an ExceptionGroup of all errors if *all_errors* is True. 1431s """ 1431s 1431s host, port = address 1431s exceptions = [] 1431s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1431s af, socktype, proto, canonname, sa = res 1431s sock = None 1431s try: 1431s sock = socket(af, socktype, proto) 1431s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1431s sock.settimeout(timeout) 1431s if source_address: 1431s sock.bind(source_address) 1431s > sock.connect(sa) 1431s E ConnectionRefusedError: [Errno 111] Connection refused 1431s 1431s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1431s 1431s During handling of the above exception, another exception occurred: 1431s 1431s self = 1431s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1431s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1431s 1431s def __init__( 1431s self, 1431s engine: Engine, 1431s connection: Optional[PoolProxiedConnection] = None, 1431s _has_events: Optional[bool] = None, 1431s _allow_revalidate: bool = True, 1431s _allow_autobegin: bool = True, 1431s ): 1431s """Construct a new Connection.""" 1431s self.engine = engine 1431s self.dialect = dialect = engine.dialect 1431s 1431s if connection is None: 1431s try: 1431s > self._dbapi_connection = engine.raw_connection() 1431s 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1431s if sock is None: 1431s if self.unix_socket: 1431s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1431s sock.settimeout(self.connect_timeout) 1431s sock.connect(self.unix_socket) 1431s self.host_info = "Localhost via UNIX socket" 1431s self._secure = True 1431s if DEBUG: 1431s print("connected using unix_socket") 1431s else: 1431s kwargs = {} 1431s if self.bind_address is not None: 1431s kwargs["source_address"] = (self.bind_address, 0) 1431s while True: 1431s try: 1431s sock = socket.create_connection( 1431s (self.host, self.port), self.connect_timeout, **kwargs 1431s ) 1431s break 1431s except OSError as e: 1431s if e.errno == errno.EINTR: 1431s continue 1431s raise 1431s self.host_info = "socket %s:%d" % (self.host, self.port) 1431s if DEBUG: 1431s print("connected using socket") 1431s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1431s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1431s sock.settimeout(None) 1431s 1431s self._sock = sock 1431s self._rfile = sock.makefile("rb") 1431s self._next_seq_id = 0 1431s 1431s self._get_server_information() 1431s self._request_authentication() 1431s 1431s # Send "SET NAMES" query on init for: 1431s # - Ensure charaset (and collation) is set to the server. 1431s # - collation_id in handshake packet may be ignored. 1431s # - If collation is not specified, we don't know what is server's 1431s # default collation for the charset. For example, default collation 1431s # of utf8mb4 is: 1431s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1431s # - MySQL 8.0: utf8mb4_0900_ai_ci 1431s # 1431s # Reference: 1431s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1431s # - https://github.com/wagtail/wagtail/issues/9477 1431s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1431s self.set_character_set(self.charset, self.collation) 1431s 1431s if self.sql_mode is not None: 1431s c = self.cursor() 1431s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1431s c.close() 1431s 1431s if self.init_command is not None: 1431s c = self.cursor() 1431s c.execute(self.init_command) 1431s c.close() 1431s 1431s if self.autocommit_mode is not None: 1431s self.autocommit(self.autocommit_mode) 1431s except BaseException as e: 1431s self._rfile = None 1431s if sock is not None: 1431s try: 1431s sock.close() 1431s except: # noqa 1431s pass 1431s 1431s if isinstance(e, (OSError, IOError)): 1431s exc = err.OperationalError( 1431s CR.CR_CONN_HOST_ERROR, 1431s f"Can't connect to MySQL server on {self.host!r} ({e})", 1431s ) 1431s # Keep original exception and traceback to investigate error. 1431s exc.original_exception = e 1431s exc.traceback = traceback.format_exc() 1431s if DEBUG: 1431s print(exc.traceback) 1431s > raise exc 1431s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1431s 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1431s 1431s The above exception was the direct cause of the following exception: 1431s 1431s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1431s request = > 1431s 1431s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1431s def test_nan_numeric(conn, request): 1431s # NaNs in numeric float column 1431s conn = request.getfixturevalue(conn) 1431s df = DataFrame({"A": [0, 1, 2], "B": [0.2, np.nan, 5.6]}) 1431s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 1431s 1431s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3057: 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1431s return func(*args, **kwargs) 1431s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1431s return sql.to_sql( 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1431s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1431s return SQLDatabase(con, schema, need_transaction) 1431s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1431s con = self.exit_stack.enter_context(con.connect()) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1431s return self._connection_cls(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1431s Connection._handle_dbapi_exception_noconnection( 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1431s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1431s self._dbapi_connection = engine.raw_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1431s return self.pool.connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1431s return _ConnectionFairy._checkout(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1431s fairy = _ConnectionRecord.checkout(pool) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1431s rec = pool._do_get() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1431s return self._create_connection() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1431s return _ConnectionRecord(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1431s self.__connect() 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1431s with util.safe_reraise(): 1431s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1431s raise exc_value.with_traceback(exc_tb) 1431s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1431s self.dbapi_connection = connection = pool._invoke_creator(self) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1431s return dialect.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1431s return self.loaded_dbapi.connect(*cargs, **cparams) 1431s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1431s self.connect() 1431s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1431s 1431s self = , sock = None 1431s 1431s def connect(self, sock=None): 1431s self._closed = False 1431s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _____________________ test_nan_numeric[mysql_pymysql_conn] _____________________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_nan_numeric(conn, request): 1432s # NaNs in numeric float column 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3055: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _________________ test_nan_numeric[postgresql_psycopg2_engine] _________________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_nan_numeric(conn, request): 1432s # NaNs in numeric float column 1432s conn = request.getfixturevalue(conn) 1432s df = DataFrame({"A": [0, 1, 2], "B": [0.2, np.nan, 5.6]}) 1432s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3057: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s __________________ test_nan_numeric[postgresql_psycopg2_conn] __________________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_nan_numeric(conn, request): 1432s # NaNs in numeric float column 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3055: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s __________________ test_nan_fullcolumn[mysql_pymysql_engine] ___________________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_nan_fullcolumn(conn, request): 1432s # full NaN column (numeric float column) 1432s conn = request.getfixturevalue(conn) 1432s df = DataFrame({"A": [0, 1, 2], "B": [np.nan, np.nan, np.nan]}) 1432s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3073: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s ___________________ test_nan_fullcolumn[mysql_pymysql_conn] ____________________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_nan_fullcolumn(conn, request): 1432s # full NaN column (numeric float column) 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3071: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _______________ test_nan_fullcolumn[postgresql_psycopg2_engine] ________________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_nan_fullcolumn(conn, request): 1432s # full NaN column (numeric float column) 1432s conn = request.getfixturevalue(conn) 1432s df = DataFrame({"A": [0, 1, 2], "B": [np.nan, np.nan, np.nan]}) 1432s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3073: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s ________________ test_nan_fullcolumn[postgresql_psycopg2_conn] _________________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_nan_fullcolumn(conn, request): 1432s # full NaN column (numeric float column) 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3071: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s ____________________ test_nan_string[mysql_pymysql_engine] _____________________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_nan_string(conn, request): 1432s # NaNs in string column 1432s conn = request.getfixturevalue(conn) 1432s df = DataFrame({"A": [0, 1, 2], "B": ["a", "b", np.nan]}) 1432s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3091: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _____________________ test_nan_string[mysql_pymysql_conn] ______________________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_nan_string(conn, request): 1432s # NaNs in string column 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3089: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _________________ test_nan_string[postgresql_psycopg2_engine] __________________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_nan_string(conn, request): 1432s # NaNs in string column 1432s conn = request.getfixturevalue(conn) 1432s df = DataFrame({"A": [0, 1, 2], "B": ["a", "b", np.nan]}) 1432s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3091: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s __________________ test_nan_string[postgresql_psycopg2_conn] ___________________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_nan_string(conn, request): 1432s # NaNs in string column 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3089: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _________________ test_to_sql_save_index[mysql_pymysql_engine] _________________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s def test_to_sql_save_index(conn, request): 1432s if "adbc" in conn: 1432s request.node.add_marker( 1432s pytest.mark.xfail( 1432s reason="ADBC implementation does not create index", strict=True 1432s ) 1432s ) 1432s conn_name = conn 1432s conn = request.getfixturevalue(conn) 1432s df = DataFrame.from_records( 1432s [(1, 2.1, "line1"), (2, 1.5, "line2")], columns=["A", "B", "C"], index=["A"] 1432s ) 1432s 1432s tbl_name = "test_to_sql_saves_index" 1432s > with pandasSQL_builder(conn) as pandasSQL: 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3120: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s __________________ test_to_sql_save_index[mysql_pymysql_conn] __________________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s def test_to_sql_save_index(conn, request): 1432s if "adbc" in conn: 1432s request.node.add_marker( 1432s pytest.mark.xfail( 1432s reason="ADBC implementation does not create index", strict=True 1432s ) 1432s ) 1432s conn_name = conn 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3114: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s ______________ test_to_sql_save_index[postgresql_psycopg2_engine] ______________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s def test_to_sql_save_index(conn, request): 1432s if "adbc" in conn: 1432s request.node.add_marker( 1432s pytest.mark.xfail( 1432s reason="ADBC implementation does not create index", strict=True 1432s ) 1432s ) 1432s conn_name = conn 1432s conn = request.getfixturevalue(conn) 1432s df = DataFrame.from_records( 1432s [(1, 2.1, "line1"), (2, 1.5, "line2")], columns=["A", "B", "C"], index=["A"] 1432s ) 1432s 1432s tbl_name = "test_to_sql_saves_index" 1432s > with pandasSQL_builder(conn) as pandasSQL: 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3120: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _______________ test_to_sql_save_index[postgresql_psycopg2_conn] _______________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s def test_to_sql_save_index(conn, request): 1432s if "adbc" in conn: 1432s request.node.add_marker( 1432s pytest.mark.xfail( 1432s reason="ADBC implementation does not create index", strict=True 1432s ) 1432s ) 1432s conn_name = conn 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3114: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s ___________________ test_transactions[mysql_pymysql_engine] ____________________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s def test_transactions(conn, request): 1432s conn_name = conn 1432s conn = request.getfixturevalue(conn) 1432s 1432s stmt = "CREATE TABLE test_trans (A INT, B TEXT)" 1432s if conn_name != "sqlite_buildin" and "adbc" not in conn_name: 1432s from sqlalchemy import text 1432s 1432s stmt = text(stmt) 1432s 1432s > with pandasSQL_builder(conn) as pandasSQL: 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3156: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s ____________________ test_transactions[mysql_pymysql_conn] _____________________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s def test_transactions(conn, request): 1432s conn_name = conn 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3148: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s ________________ test_transactions[postgresql_psycopg2_engine] _________________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s def test_transactions(conn, request): 1432s conn_name = conn 1432s conn = request.getfixturevalue(conn) 1432s 1432s stmt = "CREATE TABLE test_trans (A INT, B TEXT)" 1432s if conn_name != "sqlite_buildin" and "adbc" not in conn_name: 1432s from sqlalchemy import text 1432s 1432s stmt = text(stmt) 1432s 1432s > with pandasSQL_builder(conn) as pandasSQL: 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3156: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _________________ test_transactions[postgresql_psycopg2_conn] __________________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s def test_transactions(conn, request): 1432s conn_name = conn 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3148: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _______________ test_transaction_rollback[mysql_pymysql_engine] ________________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s def test_transaction_rollback(conn, request): 1432s conn_name = conn 1432s conn = request.getfixturevalue(conn) 1432s > with pandasSQL_builder(conn) as pandasSQL: 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3165: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s ________________ test_transaction_rollback[mysql_pymysql_conn] _________________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s def test_transaction_rollback(conn, request): 1432s conn_name = conn 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3164: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s ____________ test_transaction_rollback[postgresql_psycopg2_engine] _____________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s def test_transaction_rollback(conn, request): 1432s conn_name = conn 1432s conn = request.getfixturevalue(conn) 1432s > with pandasSQL_builder(conn) as pandasSQL: 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3165: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _____________ test_transaction_rollback[postgresql_psycopg2_conn] ______________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s def test_transaction_rollback(conn, request): 1432s conn_name = conn 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3164: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s ______________ test_get_schema_create_table[mysql_pymysql_engine] ______________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1432s request = > 1432s test_frame3 = index A B 1432s 0 2000-01-03 00:00:00 2147483647 -1.987670 1432s 1 2000-01-04 00:00:00 -29 -0.041232 1432s 2 2000-01-05 00:00:00 20000 0.731168 1432s 3 2000-01-06 00:00:00 -290867 1.567621 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_get_schema_create_table(conn, request, test_frame3): 1432s # Use a dataframe without a bool column, since MySQL converts bool to 1432s # TINYINT (which read_sql_table returns as an int and causes a dtype 1432s # mismatch) 1432s if conn == "sqlite_str": 1432s request.applymarker( 1432s pytest.mark.xfail(reason="test does not support sqlite_str fixture") 1432s ) 1432s 1432s conn = request.getfixturevalue(conn) 1432s 1432s from sqlalchemy import text 1432s from sqlalchemy.engine import Engine 1432s 1432s tbl = "test_get_schema_create_table" 1432s > create_sql = sql.get_schema(test_frame3, tbl, con=conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3219: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 1432s with pandasSQL_builder(con=con) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _______________ test_get_schema_create_table[mysql_pymysql_conn] _______________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s test_frame3 = index A B 1432s 0 2000-01-03 00:00:00 2147483647 -1.987670 1432s 1 2000-01-04 00:00:00 -29 -0.041232 1432s 2 2000-01-05 00:00:00 20000 0.731168 1432s 3 2000-01-06 00:00:00 -290867 1.567621 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_get_schema_create_table(conn, request, test_frame3): 1432s # Use a dataframe without a bool column, since MySQL converts bool to 1432s # TINYINT (which read_sql_table returns as an int and causes a dtype 1432s # mismatch) 1432s if conn == "sqlite_str": 1432s request.applymarker( 1432s pytest.mark.xfail(reason="test does not support sqlite_str fixture") 1432s ) 1432s 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3213: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s ___________ test_get_schema_create_table[postgresql_psycopg2_engine] ___________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s test_frame3 = index A B 1432s 0 2000-01-03 00:00:00 2147483647 -1.987670 1432s 1 2000-01-04 00:00:00 -29 -0.041232 1432s 2 2000-01-05 00:00:00 20000 0.731168 1432s 3 2000-01-06 00:00:00 -290867 1.567621 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_get_schema_create_table(conn, request, test_frame3): 1432s # Use a dataframe without a bool column, since MySQL converts bool to 1432s # TINYINT (which read_sql_table returns as an int and causes a dtype 1432s # mismatch) 1432s if conn == "sqlite_str": 1432s request.applymarker( 1432s pytest.mark.xfail(reason="test does not support sqlite_str fixture") 1432s ) 1432s 1432s conn = request.getfixturevalue(conn) 1432s 1432s from sqlalchemy import text 1432s from sqlalchemy.engine import Engine 1432s 1432s tbl = "test_get_schema_create_table" 1432s > create_sql = sql.get_schema(test_frame3, tbl, con=conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3219: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 1432s with pandasSQL_builder(con=con) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s ____________ test_get_schema_create_table[postgresql_psycopg2_conn] ____________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s test_frame3 = index A B 1432s 0 2000-01-03 00:00:00 2147483647 -1.987670 1432s 1 2000-01-04 00:00:00 -29 -0.041232 1432s 2 2000-01-05 00:00:00 20000 0.731168 1432s 3 2000-01-06 00:00:00 -290867 1.567621 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_get_schema_create_table(conn, request, test_frame3): 1432s # Use a dataframe without a bool column, since MySQL converts bool to 1432s # TINYINT (which read_sql_table returns as an int and causes a dtype 1432s # mismatch) 1432s if conn == "sqlite_str": 1432s request.applymarker( 1432s pytest.mark.xfail(reason="test does not support sqlite_str fixture") 1432s ) 1432s 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3213: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _______________________ test_dtype[mysql_pymysql_engine] _______________________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_dtype(conn, request): 1432s if conn == "sqlite_str": 1432s pytest.skip("sqlite_str has no inspection system") 1432s 1432s conn = request.getfixturevalue(conn) 1432s 1432s from sqlalchemy import ( 1432s TEXT, 1432s String, 1432s ) 1432s from sqlalchemy.schema import MetaData 1432s 1432s cols = ["A", "B"] 1432s data = [(0.8, True), (0.9, None)] 1432s df = DataFrame(data, columns=cols) 1432s > assert df.to_sql(name="dtype_test", con=conn) == 2 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3249: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s ________________________ test_dtype[mysql_pymysql_conn] ________________________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_dtype(conn, request): 1432s if conn == "sqlite_str": 1432s pytest.skip("sqlite_str has no inspection system") 1432s 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3238: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s ____________________ test_dtype[postgresql_psycopg2_engine] ____________________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_dtype(conn, request): 1432s if conn == "sqlite_str": 1432s pytest.skip("sqlite_str has no inspection system") 1432s 1432s conn = request.getfixturevalue(conn) 1432s 1432s from sqlalchemy import ( 1432s TEXT, 1432s String, 1432s ) 1432s from sqlalchemy.schema import MetaData 1432s 1432s cols = ["A", "B"] 1432s data = [(0.8, True), (0.9, None)] 1432s df = DataFrame(data, columns=cols) 1432s > assert df.to_sql(name="dtype_test", con=conn) == 2 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3249: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _____________________ test_dtype[postgresql_psycopg2_conn] _____________________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_dtype(conn, request): 1432s if conn == "sqlite_str": 1432s pytest.skip("sqlite_str has no inspection system") 1432s 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3238: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s ____________________ test_notna_dtype[mysql_pymysql_engine] ____________________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_notna_dtype(conn, request): 1432s if conn == "sqlite_str": 1432s pytest.skip("sqlite_str has no inspection system") 1432s 1432s conn_name = conn 1432s conn = request.getfixturevalue(conn) 1432s 1432s from sqlalchemy import ( 1432s Boolean, 1432s DateTime, 1432s Float, 1432s Integer, 1432s ) 1432s from sqlalchemy.schema import MetaData 1432s 1432s cols = { 1432s "Bool": Series([True, None]), 1432s "Date": Series([datetime(2012, 5, 1), None]), 1432s "Int": Series([1, None], dtype="object"), 1432s "Float": Series([1.1, None]), 1432s } 1432s df = DataFrame(cols) 1432s 1432s tbl = "notna_dtype_test" 1432s > assert df.to_sql(name=tbl, con=conn) == 2 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3300: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _____________________ test_notna_dtype[mysql_pymysql_conn] _____________________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_notna_dtype(conn, request): 1432s if conn == "sqlite_str": 1432s pytest.skip("sqlite_str has no inspection system") 1432s 1432s conn_name = conn 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3281: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _________________ test_notna_dtype[postgresql_psycopg2_engine] _________________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_notna_dtype(conn, request): 1432s if conn == "sqlite_str": 1432s pytest.skip("sqlite_str has no inspection system") 1432s 1432s conn_name = conn 1432s conn = request.getfixturevalue(conn) 1432s 1432s from sqlalchemy import ( 1432s Boolean, 1432s DateTime, 1432s Float, 1432s Integer, 1432s ) 1432s from sqlalchemy.schema import MetaData 1432s 1432s cols = { 1432s "Bool": Series([True, None]), 1432s "Date": Series([datetime(2012, 5, 1), None]), 1432s "Int": Series([1, None], dtype="object"), 1432s "Float": Series([1.1, None]), 1432s } 1432s df = DataFrame(cols) 1432s 1432s tbl = "notna_dtype_test" 1432s > assert df.to_sql(name=tbl, con=conn) == 2 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3300: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s __________________ test_notna_dtype[postgresql_psycopg2_conn] __________________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_notna_dtype(conn, request): 1432s if conn == "sqlite_str": 1432s pytest.skip("sqlite_str has no inspection system") 1432s 1432s conn_name = conn 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3281: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _________________ test_double_precision[mysql_pymysql_engine] __________________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_double_precision(conn, request): 1432s if conn == "sqlite_str": 1432s pytest.skip("sqlite_str has no inspection system") 1432s 1432s conn = request.getfixturevalue(conn) 1432s 1432s from sqlalchemy import ( 1432s BigInteger, 1432s Float, 1432s Integer, 1432s ) 1432s from sqlalchemy.schema import MetaData 1432s 1432s V = 1.23456789101112131415 1432s 1432s df = DataFrame( 1432s { 1432s "f32": Series([V], dtype="float32"), 1432s "f64": Series([V], dtype="float64"), 1432s "f64_as_f32": Series([V], dtype="float64"), 1432s "i32": Series([5], dtype="int32"), 1432s "i64": Series([5], dtype="int64"), 1432s } 1432s ) 1432s 1432s assert ( 1432s > df.to_sql( 1432s name="test_dtypes", 1432s con=conn, 1432s index=False, 1432s if_exists="replace", 1432s dtype={"f64_as_f32": Float(precision=23)}, 1432s ) 1432s == 1 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3339: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s __________________ test_double_precision[mysql_pymysql_conn] ___________________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_double_precision(conn, request): 1432s if conn == "sqlite_str": 1432s pytest.skip("sqlite_str has no inspection system") 1432s 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3317: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s ______________ test_double_precision[postgresql_psycopg2_engine] _______________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_double_precision(conn, request): 1432s if conn == "sqlite_str": 1432s pytest.skip("sqlite_str has no inspection system") 1432s 1432s conn = request.getfixturevalue(conn) 1432s 1432s from sqlalchemy import ( 1432s BigInteger, 1432s Float, 1432s Integer, 1432s ) 1432s from sqlalchemy.schema import MetaData 1432s 1432s V = 1.23456789101112131415 1432s 1432s df = DataFrame( 1432s { 1432s "f32": Series([V], dtype="float32"), 1432s "f64": Series([V], dtype="float64"), 1432s "f64_as_f32": Series([V], dtype="float64"), 1432s "i32": Series([5], dtype="int32"), 1432s "i64": Series([5], dtype="int64"), 1432s } 1432s ) 1432s 1432s assert ( 1432s > df.to_sql( 1432s name="test_dtypes", 1432s con=conn, 1432s index=False, 1432s if_exists="replace", 1432s dtype={"f64_as_f32": Float(precision=23)}, 1432s ) 1432s == 1 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3339: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _______________ test_double_precision[postgresql_psycopg2_conn] ________________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_double_precision(conn, request): 1432s if conn == "sqlite_str": 1432s pytest.skip("sqlite_str has no inspection system") 1432s 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3317: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _____________ test_connectable_issue_example[mysql_pymysql_engine] _____________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_connectable_issue_example(conn, request): 1432s conn = request.getfixturevalue(conn) 1432s 1432s # This tests the example raised in issue 1432s # https://github.com/pandas-dev/pandas/issues/10104 1432s from sqlalchemy.engine import Engine 1432s 1432s def test_select(connection): 1432s query = "SELECT test_foo_data FROM test_foo_data" 1432s return sql.read_sql_query(query, con=connection) 1432s 1432s def test_append(connection, data): 1432s data.to_sql(name="test_foo_data", con=connection, if_exists="append") 1432s 1432s def test_connectable(conn): 1432s # https://github.com/sqlalchemy/sqlalchemy/commit/ 1432s # 00b5c10846e800304caa86549ab9da373b42fa5d#r48323973 1432s foo_data = test_select(conn) 1432s test_append(conn, foo_data) 1432s 1432s def main(connectable): 1432s if isinstance(connectable, Engine): 1432s with connectable.connect() as conn: 1432s with conn.begin(): 1432s test_connectable(conn) 1432s else: 1432s test_connectable(connectable) 1432s 1432s assert ( 1432s > DataFrame({"test_foo_data": [0, 1, 2]}).to_sql(name="test_foo_data", con=conn) 1432s == 3 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3394: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s ______________ test_connectable_issue_example[mysql_pymysql_conn] ______________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_connectable_issue_example(conn, request): 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3366: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s __________ test_connectable_issue_example[postgresql_psycopg2_engine] __________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_connectable_issue_example(conn, request): 1432s conn = request.getfixturevalue(conn) 1432s 1432s # This tests the example raised in issue 1432s # https://github.com/pandas-dev/pandas/issues/10104 1432s from sqlalchemy.engine import Engine 1432s 1432s def test_select(connection): 1432s query = "SELECT test_foo_data FROM test_foo_data" 1432s return sql.read_sql_query(query, con=connection) 1432s 1432s def test_append(connection, data): 1432s data.to_sql(name="test_foo_data", con=connection, if_exists="append") 1432s 1432s def test_connectable(conn): 1432s # https://github.com/sqlalchemy/sqlalchemy/commit/ 1432s # 00b5c10846e800304caa86549ab9da373b42fa5d#r48323973 1432s foo_data = test_select(conn) 1432s test_append(conn, foo_data) 1432s 1432s def main(connectable): 1432s if isinstance(connectable, Engine): 1432s with connectable.connect() as conn: 1432s with conn.begin(): 1432s test_connectable(conn) 1432s else: 1432s test_connectable(connectable) 1432s 1432s assert ( 1432s > DataFrame({"test_foo_data": [0, 1, 2]}).to_sql(name="test_foo_data", con=conn) 1432s == 3 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3394: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s ___________ test_connectable_issue_example[postgresql_psycopg2_conn] ___________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_connectable_issue_example(conn, request): 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3366: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _________ test_to_sql_with_negative_npinf[input0-mysql_pymysql_engine] _________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1432s request = > 1432s input = {'foo': [inf]} 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s @pytest.mark.parametrize( 1432s "input", 1432s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1432s ) 1432s def test_to_sql_with_negative_npinf(conn, request, input): 1432s # GH 34431 1432s 1432s df = DataFrame(input) 1432s conn_name = conn 1432s conn = request.getfixturevalue(conn) 1432s 1432s if "mysql" in conn_name: 1432s # GH 36465 1432s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 1432s # for pymysql version >= 0.10 1432s # TODO(GH#36465): remove this version check after GH 36465 is fixed 1432s pymysql = td.versioned_importorskip("pymysql") 1432s 1432s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 1432s mark = pytest.mark.xfail(reason="GH 36465") 1432s request.applymarker(mark) 1432s 1432s msg = "inf cannot be used with MySQL" 1432s with pytest.raises(ValueError, match=msg): 1432s > df.to_sql(name="foobar", con=conn, index=False) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3425: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s __________ test_to_sql_with_negative_npinf[input0-mysql_pymysql_conn] __________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s input = {'foo': [inf]} 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s @pytest.mark.parametrize( 1432s "input", 1432s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1432s ) 1432s def test_to_sql_with_negative_npinf(conn, request, input): 1432s # GH 34431 1432s 1432s df = DataFrame(input) 1432s conn_name = conn 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s ______ test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_engine] ______ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s input = {'foo': [inf]} 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s @pytest.mark.parametrize( 1432s "input", 1432s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1432s ) 1432s def test_to_sql_with_negative_npinf(conn, request, input): 1432s # GH 34431 1432s 1432s df = DataFrame(input) 1432s conn_name = conn 1432s conn = request.getfixturevalue(conn) 1432s 1432s if "mysql" in conn_name: 1432s # GH 36465 1432s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 1432s # for pymysql version >= 0.10 1432s # TODO(GH#36465): remove this version check after GH 36465 is fixed 1432s pymysql = td.versioned_importorskip("pymysql") 1432s 1432s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 1432s mark = pytest.mark.xfail(reason="GH 36465") 1432s request.applymarker(mark) 1432s 1432s msg = "inf cannot be used with MySQL" 1432s with pytest.raises(ValueError, match=msg): 1432s df.to_sql(name="foobar", con=conn, index=False) 1432s else: 1432s > assert df.to_sql(name="foobar", con=conn, index=False) == 1 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3427: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _______ test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_conn] _______ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s input = {'foo': [inf]} 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s @pytest.mark.parametrize( 1432s "input", 1432s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1432s ) 1432s def test_to_sql_with_negative_npinf(conn, request, input): 1432s # GH 34431 1432s 1432s df = DataFrame(input) 1432s conn_name = conn 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _________ test_to_sql_with_negative_npinf[input1-mysql_pymysql_engine] _________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1432s request = > 1432s input = {'foo': [-inf]} 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s @pytest.mark.parametrize( 1432s "input", 1432s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1432s ) 1432s def test_to_sql_with_negative_npinf(conn, request, input): 1432s # GH 34431 1432s 1432s df = DataFrame(input) 1432s conn_name = conn 1432s conn = request.getfixturevalue(conn) 1432s 1432s if "mysql" in conn_name: 1432s # GH 36465 1432s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 1432s # for pymysql version >= 0.10 1432s # TODO(GH#36465): remove this version check after GH 36465 is fixed 1432s pymysql = td.versioned_importorskip("pymysql") 1432s 1432s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 1432s mark = pytest.mark.xfail(reason="GH 36465") 1432s request.applymarker(mark) 1432s 1432s msg = "inf cannot be used with MySQL" 1432s with pytest.raises(ValueError, match=msg): 1432s > df.to_sql(name="foobar", con=conn, index=False) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3425: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s __________ test_to_sql_with_negative_npinf[input1-mysql_pymysql_conn] __________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s input = {'foo': [-inf]} 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s @pytest.mark.parametrize( 1432s "input", 1432s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1432s ) 1432s def test_to_sql_with_negative_npinf(conn, request, input): 1432s # GH 34431 1432s 1432s df = DataFrame(input) 1432s conn_name = conn 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s ______ test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_engine] ______ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s input = {'foo': [-inf]} 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s @pytest.mark.parametrize( 1432s "input", 1432s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1432s ) 1432s def test_to_sql_with_negative_npinf(conn, request, input): 1432s # GH 34431 1432s 1432s df = DataFrame(input) 1432s conn_name = conn 1432s conn = request.getfixturevalue(conn) 1432s 1432s if "mysql" in conn_name: 1432s # GH 36465 1432s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 1432s # for pymysql version >= 0.10 1432s # TODO(GH#36465): remove this version check after GH 36465 is fixed 1432s pymysql = td.versioned_importorskip("pymysql") 1432s 1432s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 1432s mark = pytest.mark.xfail(reason="GH 36465") 1432s request.applymarker(mark) 1432s 1432s msg = "inf cannot be used with MySQL" 1432s with pytest.raises(ValueError, match=msg): 1432s df.to_sql(name="foobar", con=conn, index=False) 1432s else: 1432s > assert df.to_sql(name="foobar", con=conn, index=False) == 1 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3427: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _______ test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_conn] _______ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s input = {'foo': [-inf]} 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s @pytest.mark.parametrize( 1432s "input", 1432s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1432s ) 1432s def test_to_sql_with_negative_npinf(conn, request, input): 1432s # GH 34431 1432s 1432s df = DataFrame(input) 1432s conn_name = conn 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _________ test_to_sql_with_negative_npinf[input2-mysql_pymysql_engine] _________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1432s request = > 1432s input = {'foo': [-inf], 'infe0': ['bar']} 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s @pytest.mark.parametrize( 1432s "input", 1432s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1432s ) 1432s def test_to_sql_with_negative_npinf(conn, request, input): 1432s # GH 34431 1432s 1432s df = DataFrame(input) 1432s conn_name = conn 1432s conn = request.getfixturevalue(conn) 1432s 1432s if "mysql" in conn_name: 1432s # GH 36465 1432s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 1432s # for pymysql version >= 0.10 1432s # TODO(GH#36465): remove this version check after GH 36465 is fixed 1432s pymysql = td.versioned_importorskip("pymysql") 1432s 1432s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 1432s mark = pytest.mark.xfail(reason="GH 36465") 1432s request.applymarker(mark) 1432s 1432s msg = "inf cannot be used with MySQL" 1432s with pytest.raises(ValueError, match=msg): 1432s > df.to_sql(name="foobar", con=conn, index=False) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3425: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s __________ test_to_sql_with_negative_npinf[input2-mysql_pymysql_conn] __________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s input = {'foo': [-inf], 'infe0': ['bar']} 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s @pytest.mark.parametrize( 1432s "input", 1432s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1432s ) 1432s def test_to_sql_with_negative_npinf(conn, request, input): 1432s # GH 34431 1432s 1432s df = DataFrame(input) 1432s conn_name = conn 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s ______ test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_engine] ______ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s input = {'foo': [-inf], 'infe0': ['bar']} 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s @pytest.mark.parametrize( 1432s "input", 1432s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1432s ) 1432s def test_to_sql_with_negative_npinf(conn, request, input): 1432s # GH 34431 1432s 1432s df = DataFrame(input) 1432s conn_name = conn 1432s conn = request.getfixturevalue(conn) 1432s 1432s if "mysql" in conn_name: 1432s # GH 36465 1432s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 1432s # for pymysql version >= 0.10 1432s # TODO(GH#36465): remove this version check after GH 36465 is fixed 1432s pymysql = td.versioned_importorskip("pymysql") 1432s 1432s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 1432s mark = pytest.mark.xfail(reason="GH 36465") 1432s request.applymarker(mark) 1432s 1432s msg = "inf cannot be used with MySQL" 1432s with pytest.raises(ValueError, match=msg): 1432s df.to_sql(name="foobar", con=conn, index=False) 1432s else: 1432s > assert df.to_sql(name="foobar", con=conn, index=False) == 1 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3427: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _______ test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_conn] _______ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s input = {'foo': [-inf], 'infe0': ['bar']} 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s @pytest.mark.parametrize( 1432s "input", 1432s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1432s ) 1432s def test_to_sql_with_negative_npinf(conn, request, input): 1432s # GH 34431 1432s 1432s df = DataFrame(input) 1432s conn_name = conn 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s __________________ test_temporary_table[mysql_pymysql_engine] __________________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_temporary_table(conn, request): 1432s if conn == "sqlite_str": 1432s pytest.skip("test does not work with str connection") 1432s 1432s conn = request.getfixturevalue(conn) 1432s 1432s from sqlalchemy import ( 1432s Column, 1432s Integer, 1432s Unicode, 1432s select, 1432s ) 1432s from sqlalchemy.orm import ( 1432s Session, 1432s declarative_base, 1432s ) 1432s 1432s test_data = "Hello, World!" 1432s expected = DataFrame({"spam": [test_data]}) 1432s Base = declarative_base() 1432s 1432s class Temporary(Base): 1432s __tablename__ = "temp_test" 1432s __table_args__ = {"prefixes": ["TEMPORARY"]} 1432s id = Column(Integer, primary_key=True) 1432s spam = Column(Unicode(30), nullable=False) 1432s 1432s with Session(conn) as session: 1432s with session.begin(): 1432s > conn = session.connection() 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3462: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:2094: in connection 1432s return self._connection_for_bind( 1432s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:2110: in _connection_for_bind 1432s return trans._connection_for_bind(engine, execution_options) 1432s :2: in _connection_for_bind 1432s ??? 1432s /usr/lib/python3/dist-packages/sqlalchemy/orm/state_changes.py:139: in _go 1432s ret_value = fn(self, *arg, **kw) 1432s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:1189: in _connection_for_bind 1432s conn = bind.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s ___________________ test_temporary_table[mysql_pymysql_conn] ___________________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_temporary_table(conn, request): 1432s if conn == "sqlite_str": 1432s pytest.skip("test does not work with str connection") 1432s 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3437: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _______________ test_temporary_table[postgresql_psycopg2_engine] _______________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_temporary_table(conn, request): 1432s if conn == "sqlite_str": 1432s pytest.skip("test does not work with str connection") 1432s 1432s conn = request.getfixturevalue(conn) 1432s 1432s from sqlalchemy import ( 1432s Column, 1432s Integer, 1432s Unicode, 1432s select, 1432s ) 1432s from sqlalchemy.orm import ( 1432s Session, 1432s declarative_base, 1432s ) 1432s 1432s test_data = "Hello, World!" 1432s expected = DataFrame({"spam": [test_data]}) 1432s Base = declarative_base() 1432s 1432s class Temporary(Base): 1432s __tablename__ = "temp_test" 1432s __table_args__ = {"prefixes": ["TEMPORARY"]} 1432s id = Column(Integer, primary_key=True) 1432s spam = Column(Unicode(30), nullable=False) 1432s 1432s with Session(conn) as session: 1432s with session.begin(): 1432s > conn = session.connection() 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3462: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:2094: in connection 1432s return self._connection_for_bind( 1432s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:2110: in _connection_for_bind 1432s return trans._connection_for_bind(engine, execution_options) 1432s :2: in _connection_for_bind 1432s ??? 1432s /usr/lib/python3/dist-packages/sqlalchemy/orm/state_changes.py:139: in _go 1432s ret_value = fn(self, *arg, **kw) 1432s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:1189: in _connection_for_bind 1432s conn = bind.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s ________________ test_temporary_table[postgresql_psycopg2_conn] ________________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_temporary_table(conn, request): 1432s if conn == "sqlite_str": 1432s pytest.skip("test does not work with str connection") 1432s 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3437: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s __________________ test_invalid_engine[mysql_pymysql_engine] ___________________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1432s request = > 1432s test_frame1 = index A B C D 1432s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1432s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s def test_invalid_engine(conn, request, test_frame1): 1432s if conn == "sqlite_buildin" or "adbc" in conn: 1432s request.applymarker( 1432s pytest.mark.xfail( 1432s reason="SQLiteDatabase/ADBCDatabase does not raise for bad engine" 1432s ) 1432s ) 1432s 1432s conn = request.getfixturevalue(conn) 1432s msg = "engine must be one of 'auto', 'sqlalchemy'" 1432s > with pandasSQL_builder(conn) as pandasSQL: 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3481: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s ___________________ test_invalid_engine[mysql_pymysql_conn] ____________________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s test_frame1 = index A B C D 1432s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1432s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s def test_invalid_engine(conn, request, test_frame1): 1432s if conn == "sqlite_buildin" or "adbc" in conn: 1432s request.applymarker( 1432s pytest.mark.xfail( 1432s reason="SQLiteDatabase/ADBCDatabase does not raise for bad engine" 1432s ) 1432s ) 1432s 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3479: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _______________ test_invalid_engine[postgresql_psycopg2_engine] ________________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s test_frame1 = index A B C D 1432s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1432s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s def test_invalid_engine(conn, request, test_frame1): 1432s if conn == "sqlite_buildin" or "adbc" in conn: 1432s request.applymarker( 1432s pytest.mark.xfail( 1432s reason="SQLiteDatabase/ADBCDatabase does not raise for bad engine" 1432s ) 1432s ) 1432s 1432s conn = request.getfixturevalue(conn) 1432s msg = "engine must be one of 'auto', 'sqlalchemy'" 1432s > with pandasSQL_builder(conn) as pandasSQL: 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3481: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s ________________ test_invalid_engine[postgresql_psycopg2_conn] _________________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s test_frame1 = index A B C D 1432s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1432s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s def test_invalid_engine(conn, request, test_frame1): 1432s if conn == "sqlite_buildin" or "adbc" in conn: 1432s request.applymarker( 1432s pytest.mark.xfail( 1432s reason="SQLiteDatabase/ADBCDatabase does not raise for bad engine" 1432s ) 1432s ) 1432s 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3479: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s ______________ test_to_sql_with_sql_engine[mysql_pymysql_engine] _______________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1432s request = > 1432s test_frame1 = index A B C D 1432s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1432s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s def test_to_sql_with_sql_engine(conn, request, test_frame1): 1432s """`to_sql` with the `engine` param""" 1432s # mostly copied from this class's `_to_sql()` method 1432s conn = request.getfixturevalue(conn) 1432s > with pandasSQL_builder(conn) as pandasSQL: 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3491: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _______________ test_to_sql_with_sql_engine[mysql_pymysql_conn] ________________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s test_frame1 = index A B C D 1432s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1432s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s def test_to_sql_with_sql_engine(conn, request, test_frame1): 1432s """`to_sql` with the `engine` param""" 1432s # mostly copied from this class's `_to_sql()` method 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3490: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s ___________ test_to_sql_with_sql_engine[postgresql_psycopg2_engine] ____________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s test_frame1 = index A B C D 1432s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1432s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s def test_to_sql_with_sql_engine(conn, request, test_frame1): 1432s """`to_sql` with the `engine` param""" 1432s # mostly copied from this class's `_to_sql()` method 1432s conn = request.getfixturevalue(conn) 1432s > with pandasSQL_builder(conn) as pandasSQL: 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3491: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s ____________ test_to_sql_with_sql_engine[postgresql_psycopg2_conn] _____________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s test_frame1 = index A B C D 1432s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1432s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s def test_to_sql_with_sql_engine(conn, request, test_frame1): 1432s """`to_sql` with the `engine` param""" 1432s # mostly copied from this class's `_to_sql()` method 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3490: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s ________________ test_options_sqlalchemy[mysql_pymysql_engine] _________________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1432s request = > 1432s test_frame1 = index A B C D 1432s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1432s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_options_sqlalchemy(conn, request, test_frame1): 1432s # use the set option 1432s conn = request.getfixturevalue(conn) 1432s with pd.option_context("io.sql.engine", "sqlalchemy"): 1432s > with pandasSQL_builder(conn) as pandasSQL: 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3506: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _________________ test_options_sqlalchemy[mysql_pymysql_conn] __________________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s test_frame1 = index A B C D 1432s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1432s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_options_sqlalchemy(conn, request, test_frame1): 1432s # use the set option 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3504: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _____________ test_options_sqlalchemy[postgresql_psycopg2_engine] ______________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s test_frame1 = index A B C D 1432s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1432s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_options_sqlalchemy(conn, request, test_frame1): 1432s # use the set option 1432s conn = request.getfixturevalue(conn) 1432s with pd.option_context("io.sql.engine", "sqlalchemy"): 1432s > with pandasSQL_builder(conn) as pandasSQL: 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3506: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s ______________ test_options_sqlalchemy[postgresql_psycopg2_conn] _______________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s test_frame1 = index A B C D 1432s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1432s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1432s 1432s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1432s def test_options_sqlalchemy(conn, request, test_frame1): 1432s # use the set option 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3504: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s ___________________ test_options_auto[mysql_pymysql_engine] ____________________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1432s request = > 1432s test_frame1 = index A B C D 1432s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1432s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s def test_options_auto(conn, request, test_frame1): 1432s # use the set option 1432s conn = request.getfixturevalue(conn) 1432s with pd.option_context("io.sql.engine", "auto"): 1432s > with pandasSQL_builder(conn) as pandasSQL: 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3521: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s ____________________ test_options_auto[mysql_pymysql_conn] _____________________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s test_frame1 = index A B C D 1432s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1432s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s def test_options_auto(conn, request, test_frame1): 1432s # use the set option 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3519: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s ________________ test_options_auto[postgresql_psycopg2_engine] _________________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s test_frame1 = index A B C D 1432s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1432s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s def test_options_auto(conn, request, test_frame1): 1432s # use the set option 1432s conn = request.getfixturevalue(conn) 1432s with pd.option_context("io.sql.engine", "auto"): 1432s > with pandasSQL_builder(conn) as pandasSQL: 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3521: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _________________ test_options_auto[postgresql_psycopg2_conn] __________________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s test_frame1 = index A B C D 1432s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1432s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s def test_options_auto(conn, request, test_frame1): 1432s # use the set option 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3519: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_engine] _ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1432s request = > 1432s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 1432s dtype_backend_data = a b c d e f g h 1432s 0 1 1 1.5 1.5 True True a a 1432s 1 2 2.0 False False b b 1432s 2 3 3 2.5 2.5 None True c None 1432s dtype_backend_expected = .func at 0x3ff9a20ac00> 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1432s def test_read_sql_dtype_backend( 1432s conn, 1432s request, 1432s string_storage, 1432s func, 1432s dtype_backend, 1432s dtype_backend_data, 1432s dtype_backend_expected, 1432s ): 1432s # GH#50048 1432s conn_name = conn 1432s conn = request.getfixturevalue(conn) 1432s table = "test" 1432s df = dtype_backend_data 1432s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3567: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_conn] _ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 1432s dtype_backend_data = a b c d e f g h 1432s 0 1 1 1.5 1.5 True True a a 1432s 1 2 2.0 False False b b 1432s 2 3 3 2.5 2.5 None True c None 1432s dtype_backend_expected = .func at 0x3ff9a20ac00> 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1432s def test_read_sql_dtype_backend( 1432s conn, 1432s request, 1432s string_storage, 1432s func, 1432s dtype_backend, 1432s dtype_backend_data, 1432s dtype_backend_expected, 1432s ): 1432s # GH#50048 1432s conn_name = conn 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3564: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] _ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 1432s dtype_backend_data = a b c d e f g h 1432s 0 1 1 1.5 1.5 True True a a 1432s 1 2 2.0 False False b b 1432s 2 3 3 2.5 2.5 None True c None 1432s dtype_backend_expected = .func at 0x3ff9a20ac00> 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1432s def test_read_sql_dtype_backend( 1432s conn, 1432s request, 1432s string_storage, 1432s func, 1432s dtype_backend, 1432s dtype_backend_data, 1432s dtype_backend_expected, 1432s ): 1432s # GH#50048 1432s conn_name = conn 1432s conn = request.getfixturevalue(conn) 1432s table = "test" 1432s df = dtype_backend_data 1432s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3567: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] _ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 1432s dtype_backend_data = a b c d e f g h 1432s 0 1 1 1.5 1.5 True True a a 1432s 1 2 2.0 False False b b 1432s 2 3 3 2.5 2.5 None True c None 1432s dtype_backend_expected = .func at 0x3ff9a20ac00> 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1432s def test_read_sql_dtype_backend( 1432s conn, 1432s request, 1432s string_storage, 1432s func, 1432s dtype_backend, 1432s dtype_backend_data, 1432s dtype_backend_expected, 1432s ): 1432s # GH#50048 1432s conn_name = conn 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3564: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_engine] _ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1432s request = > 1432s string_storage = 'python', func = 'read_sql_query' 1432s dtype_backend = 'numpy_nullable' 1432s dtype_backend_data = a b c d e f g h 1432s 0 1 1 1.5 1.5 True True a a 1432s 1 2 2.0 False False b b 1432s 2 3 3 2.5 2.5 None True c None 1432s dtype_backend_expected = .func at 0x3ff9a20ad40> 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1432s def test_read_sql_dtype_backend( 1432s conn, 1432s request, 1432s string_storage, 1432s func, 1432s dtype_backend, 1432s dtype_backend_data, 1432s dtype_backend_expected, 1432s ): 1432s # GH#50048 1432s conn_name = conn 1432s conn = request.getfixturevalue(conn) 1432s table = "test" 1432s df = dtype_backend_data 1432s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3567: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_conn] _ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s string_storage = 'python', func = 'read_sql_query' 1432s dtype_backend = 'numpy_nullable' 1432s dtype_backend_data = a b c d e f g h 1432s 0 1 1 1.5 1.5 True True a a 1432s 1 2 2.0 False False b b 1432s 2 3 3 2.5 2.5 None True c None 1432s dtype_backend_expected = .func at 0x3ff9a20ad40> 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1432s def test_read_sql_dtype_backend( 1432s conn, 1432s request, 1432s string_storage, 1432s func, 1432s dtype_backend, 1432s dtype_backend_data, 1432s dtype_backend_expected, 1432s ): 1432s # GH#50048 1432s conn_name = conn 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3564: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_engine] _ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s string_storage = 'python', func = 'read_sql_query' 1432s dtype_backend = 'numpy_nullable' 1432s dtype_backend_data = a b c d e f g h 1432s 0 1 1 1.5 1.5 True True a a 1432s 1 2 2.0 False False b b 1432s 2 3 3 2.5 2.5 None True c None 1432s dtype_backend_expected = .func at 0x3ff9a20ade0> 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1432s def test_read_sql_dtype_backend( 1432s conn, 1432s request, 1432s string_storage, 1432s func, 1432s dtype_backend, 1432s dtype_backend_data, 1432s dtype_backend_expected, 1432s ): 1432s # GH#50048 1432s conn_name = conn 1432s conn = request.getfixturevalue(conn) 1432s table = "test" 1432s df = dtype_backend_data 1432s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3567: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_conn] _ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s string_storage = 'python', func = 'read_sql_query' 1432s dtype_backend = 'numpy_nullable' 1432s dtype_backend_data = a b c d e f g h 1432s 0 1 1 1.5 1.5 True True a a 1432s 1 2 2.0 False False b b 1432s 2 3 3 2.5 2.5 None True c None 1432s dtype_backend_expected = .func at 0x3ff9a20ae80> 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1432s def test_read_sql_dtype_backend( 1432s conn, 1432s request, 1432s string_storage, 1432s func, 1432s dtype_backend, 1432s dtype_backend_data, 1432s dtype_backend_expected, 1432s ): 1432s # GH#50048 1432s conn_name = conn 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3564: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_engine] _ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1432s request = > 1432s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 1432s dtype_backend_data = a b c d e f g h 1432s 0 1 1 1.5 1.5 True True a a 1432s 1 2 2.0 False False b b 1432s 2 3 3 2.5 2.5 None True c None 1432s dtype_backend_expected = .func at 0x3ff9a20b100> 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 1432s def test_read_sql_dtype_backend_table( 1432s conn, 1432s request, 1432s string_storage, 1432s func, 1432s dtype_backend, 1432s dtype_backend_data, 1432s dtype_backend_expected, 1432s ): 1432s if "sqlite" in conn and "adbc" not in conn: 1432s request.applymarker( 1432s pytest.mark.xfail( 1432s reason=( 1432s "SQLite actually returns proper boolean values via " 1432s "read_sql_table, but before pytest refactor was skipped" 1432s ) 1432s ) 1432s ) 1432s # GH#50048 1432s conn_name = conn 1432s conn = request.getfixturevalue(conn) 1432s table = "test" 1432s df = dtype_backend_data 1432s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3619: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_conn] _ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 1432s dtype_backend_data = a b c d e f g h 1432s 0 1 1 1.5 1.5 True True a a 1432s 1 2 2.0 False False b b 1432s 2 3 3 2.5 2.5 None True c None 1432s dtype_backend_expected = .func at 0x3ff9a20b100> 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 1432s def test_read_sql_dtype_backend_table( 1432s conn, 1432s request, 1432s string_storage, 1432s func, 1432s dtype_backend, 1432s dtype_backend_data, 1432s dtype_backend_expected, 1432s ): 1432s if "sqlite" in conn and "adbc" not in conn: 1432s request.applymarker( 1432s pytest.mark.xfail( 1432s reason=( 1432s "SQLite actually returns proper boolean values via " 1432s "read_sql_table, but before pytest refactor was skipped" 1432s ) 1432s ) 1432s ) 1432s # GH#50048 1432s conn_name = conn 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3616: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] _ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 1432s dtype_backend_data = a b c d e f g h 1432s 0 1 1 1.5 1.5 True True a a 1432s 1 2 2.0 False False b b 1432s 2 3 3 2.5 2.5 None True c None 1432s dtype_backend_expected = .func at 0x3ff9a20b1a0> 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 1432s def test_read_sql_dtype_backend_table( 1432s conn, 1432s request, 1432s string_storage, 1432s func, 1432s dtype_backend, 1432s dtype_backend_data, 1432s dtype_backend_expected, 1432s ): 1432s if "sqlite" in conn and "adbc" not in conn: 1432s request.applymarker( 1432s pytest.mark.xfail( 1432s reason=( 1432s "SQLite actually returns proper boolean values via " 1432s "read_sql_table, but before pytest refactor was skipped" 1432s ) 1432s ) 1432s ) 1432s # GH#50048 1432s conn_name = conn 1432s conn = request.getfixturevalue(conn) 1432s table = "test" 1432s df = dtype_backend_data 1432s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3619: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] _ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 1432s dtype_backend_data = a b c d e f g h 1432s 0 1 1 1.5 1.5 True True a a 1432s 1 2 2.0 False False b b 1432s 2 3 3 2.5 2.5 None True c None 1432s dtype_backend_expected = .func at 0x3ff9a20b240> 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 1432s def test_read_sql_dtype_backend_table( 1432s conn, 1432s request, 1432s string_storage, 1432s func, 1432s dtype_backend, 1432s dtype_backend_data, 1432s dtype_backend_expected, 1432s ): 1432s if "sqlite" in conn and "adbc" not in conn: 1432s request.applymarker( 1432s pytest.mark.xfail( 1432s reason=( 1432s "SQLite actually returns proper boolean values via " 1432s "read_sql_table, but before pytest refactor was skipped" 1432s ) 1432s ) 1432s ) 1432s # GH#50048 1432s conn_name = conn 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3616: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_engine] _ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1432s request = > 1432s string_storage = 'python', func = 'read_sql_table' 1432s dtype_backend = 'numpy_nullable' 1432s dtype_backend_data = a b c d e f g h 1432s 0 1 1 1.5 1.5 True True a a 1432s 1 2 2.0 False False b b 1432s 2 3 3 2.5 2.5 None True c None 1432s dtype_backend_expected = .func at 0x3ff9a20b6a0> 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 1432s def test_read_sql_dtype_backend_table( 1432s conn, 1432s request, 1432s string_storage, 1432s func, 1432s dtype_backend, 1432s dtype_backend_data, 1432s dtype_backend_expected, 1432s ): 1432s if "sqlite" in conn and "adbc" not in conn: 1432s request.applymarker( 1432s pytest.mark.xfail( 1432s reason=( 1432s "SQLite actually returns proper boolean values via " 1432s "read_sql_table, but before pytest refactor was skipped" 1432s ) 1432s ) 1432s ) 1432s # GH#50048 1432s conn_name = conn 1432s conn = request.getfixturevalue(conn) 1432s table = "test" 1432s df = dtype_backend_data 1432s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3619: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_conn] _ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s string_storage = 'python', func = 'read_sql_table' 1432s dtype_backend = 'numpy_nullable' 1432s dtype_backend_data = a b c d e f g h 1432s 0 1 1 1.5 1.5 True True a a 1432s 1 2 2.0 False False b b 1432s 2 3 3 2.5 2.5 None True c None 1432s dtype_backend_expected = .func at 0x3ff9a20b740> 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 1432s def test_read_sql_dtype_backend_table( 1432s conn, 1432s request, 1432s string_storage, 1432s func, 1432s dtype_backend, 1432s dtype_backend_data, 1432s dtype_backend_expected, 1432s ): 1432s if "sqlite" in conn and "adbc" not in conn: 1432s request.applymarker( 1432s pytest.mark.xfail( 1432s reason=( 1432s "SQLite actually returns proper boolean values via " 1432s "read_sql_table, but before pytest refactor was skipped" 1432s ) 1432s ) 1432s ) 1432s # GH#50048 1432s conn_name = conn 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3616: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_engine] _ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s string_storage = 'python', func = 'read_sql_table' 1432s dtype_backend = 'numpy_nullable' 1432s dtype_backend_data = a b c d e f g h 1432s 0 1 1 1.5 1.5 True True a a 1432s 1 2 2.0 False False b b 1432s 2 3 3 2.5 2.5 None True c None 1432s dtype_backend_expected = .func at 0x3ff9a20b7e0> 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 1432s def test_read_sql_dtype_backend_table( 1432s conn, 1432s request, 1432s string_storage, 1432s func, 1432s dtype_backend, 1432s dtype_backend_data, 1432s dtype_backend_expected, 1432s ): 1432s if "sqlite" in conn and "adbc" not in conn: 1432s request.applymarker( 1432s pytest.mark.xfail( 1432s reason=( 1432s "SQLite actually returns proper boolean values via " 1432s "read_sql_table, but before pytest refactor was skipped" 1432s ) 1432s ) 1432s ) 1432s # GH#50048 1432s conn_name = conn 1432s conn = request.getfixturevalue(conn) 1432s table = "test" 1432s df = dtype_backend_data 1432s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3619: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_conn] _ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s string_storage = 'python', func = 'read_sql_table' 1432s dtype_backend = 'numpy_nullable' 1432s dtype_backend_data = a b c d e f g h 1432s 0 1 1 1.5 1.5 True True a a 1432s 1 2 2.0 False False b b 1432s 2 3 3 2.5 2.5 None True c None 1432s dtype_backend_expected = .func at 0x3ff9a20b880> 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 1432s def test_read_sql_dtype_backend_table( 1432s conn, 1432s request, 1432s string_storage, 1432s func, 1432s dtype_backend, 1432s dtype_backend_data, 1432s dtype_backend_expected, 1432s ): 1432s if "sqlite" in conn and "adbc" not in conn: 1432s request.applymarker( 1432s pytest.mark.xfail( 1432s reason=( 1432s "SQLite actually returns proper boolean values via " 1432s "read_sql_table, but before pytest refactor was skipped" 1432s ) 1432s ) 1432s ) 1432s # GH#50048 1432s conn_name = conn 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3616: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s ___ test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_engine] ___ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1432s request = > 1432s func = 'read_sql' 1432s dtype_backend_data = a b c d e f g h 1432s 0 1 1 1.5 1.5 True True a a 1432s 1 2 2.0 False False b b 1432s 2 3 3 2.5 2.5 None True c None 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1432s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1432s conn = request.getfixturevalue(conn) 1432s table = "test" 1432s df = dtype_backend_data 1432s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s ____ test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_conn] ____ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s func = 'read_sql' 1432s dtype_backend_data = a b c d e f g h 1432s 0 1 1 1.5 1.5 True True a a 1432s 1 2 2.0 False False b b 1432s 2 3 3 2.5 2.5 None True c None 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1432s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _ test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_engine] _ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s func = 'read_sql' 1432s dtype_backend_data = a b c d e f g h 1432s 0 1 1 1.5 1.5 True True a a 1432s 1 2 2.0 False False b b 1432s 2 3 3 2.5 2.5 None True c None 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1432s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1432s conn = request.getfixturevalue(conn) 1432s table = "test" 1432s df = dtype_backend_data 1432s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _ test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_conn] _ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s func = 'read_sql' 1432s dtype_backend_data = a b c d e f g h 1432s 0 1 1 1.5 1.5 True True a a 1432s 1 2 2.0 False False b b 1432s 2 3 3 2.5 2.5 None True c None 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1432s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _ test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_engine] _ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1432s request = > 1432s func = 'read_sql_table' 1432s dtype_backend_data = a b c d e f g h 1432s 0 1 1 1.5 1.5 True True a a 1432s 1 2 2.0 False False b b 1432s 2 3 3 2.5 2.5 None True c None 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1432s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1432s conn = request.getfixturevalue(conn) 1432s table = "test" 1432s df = dtype_backend_data 1432s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _ test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_conn] _ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s func = 'read_sql_table' 1432s dtype_backend_data = a b c d e f g h 1432s 0 1 1 1.5 1.5 True True a a 1432s 1 2 2.0 False False b b 1432s 2 3 3 2.5 2.5 None True c None 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1432s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _ test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_engine] _ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s func = 'read_sql_table' 1432s dtype_backend_data = a b c d e f g h 1432s 0 1 1 1.5 1.5 True True a a 1432s 1 2 2.0 False False b b 1432s 2 3 3 2.5 2.5 None True c None 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1432s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1432s conn = request.getfixturevalue(conn) 1432s table = "test" 1432s df = dtype_backend_data 1432s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _ test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_conn] _ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s func = 'read_sql_table' 1432s dtype_backend_data = a b c d e f g h 1432s 0 1 1 1.5 1.5 True True a a 1432s 1 2 2.0 False False b b 1432s 2 3 3 2.5 2.5 None True c None 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1432s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _ test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_engine] _ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1432s request = > 1432s func = 'read_sql_query' 1432s dtype_backend_data = a b c d e f g h 1432s 0 1 1 1.5 1.5 True True a a 1432s 1 2 2.0 False False b b 1432s 2 3 3 2.5 2.5 None True c None 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1432s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1432s conn = request.getfixturevalue(conn) 1432s table = "test" 1432s df = dtype_backend_data 1432s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _ test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_conn] _ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s func = 'read_sql_query' 1432s dtype_backend_data = a b c d e f g h 1432s 0 1 1 1.5 1.5 True True a a 1432s 1 2 2.0 False False b b 1432s 2 3 3 2.5 2.5 None True c None 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1432s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _ test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_engine] _ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s func = 'read_sql_query' 1432s dtype_backend_data = a b c d e f g h 1432s 0 1 1 1.5 1.5 True True a a 1432s 1 2 2.0 False False b b 1432s 2 3 3 2.5 2.5 None True c None 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1432s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1432s conn = request.getfixturevalue(conn) 1432s table = "test" 1432s df = dtype_backend_data 1432s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _ test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_conn] _ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s func = 'read_sql_query' 1432s dtype_backend_data = a b c d e f g h 1432s 0 1 1 1.5 1.5 True True a a 1432s 1 2 2.0 False False b b 1432s 2 3 3 2.5 2.5 None True c None 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1432s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s ______________ test_chunksize_empty_dtypes[mysql_pymysql_engine] _______________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s def test_chunksize_empty_dtypes(conn, request): 1432s # GH#50245 1432s if "adbc" in conn: 1432s request.node.add_marker( 1432s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1432s ) 1432s conn = request.getfixturevalue(conn) 1432s dtypes = {"a": "int64", "b": "object"} 1432s df = DataFrame(columns=["a", "b"]).astype(dtypes) 1432s expected = df.copy() 1432s > df.to_sql(name="test", con=conn, index=False, if_exists="replace") 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3741: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _______________ test_chunksize_empty_dtypes[mysql_pymysql_conn] ________________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s def test_chunksize_empty_dtypes(conn, request): 1432s # GH#50245 1432s if "adbc" in conn: 1432s request.node.add_marker( 1432s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1432s ) 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3737: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s ___________ test_chunksize_empty_dtypes[postgresql_psycopg2_engine] ____________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s def test_chunksize_empty_dtypes(conn, request): 1432s # GH#50245 1432s if "adbc" in conn: 1432s request.node.add_marker( 1432s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1432s ) 1432s conn = request.getfixturevalue(conn) 1432s dtypes = {"a": "int64", "b": "object"} 1432s df = DataFrame(columns=["a", "b"]).astype(dtypes) 1432s expected = df.copy() 1432s > df.to_sql(name="test", con=conn, index=False, if_exists="replace") 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3741: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s ____________ test_chunksize_empty_dtypes[postgresql_psycopg2_conn] _____________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s def test_chunksize_empty_dtypes(conn, request): 1432s # GH#50245 1432s if "adbc" in conn: 1432s request.node.add_marker( 1432s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1432s ) 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3737: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s ___ test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_engine] ___ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1432s request = > 1432s func = 'read_sql', dtype_backend = 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1432s def test_read_sql_dtype(conn, request, func, dtype_backend): 1432s # GH#50797 1432s conn = request.getfixturevalue(conn) 1432s table = "test" 1432s df = DataFrame({"a": [1, 2, 3], "b": 5}) 1432s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s ____ test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_conn] ____ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s func = 'read_sql', dtype_backend = 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1432s def test_read_sql_dtype(conn, request, func, dtype_backend): 1432s # GH#50797 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _ test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_engine] _ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s func = 'read_sql', dtype_backend = 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1432s def test_read_sql_dtype(conn, request, func, dtype_backend): 1432s # GH#50797 1432s conn = request.getfixturevalue(conn) 1432s table = "test" 1432s df = DataFrame({"a": [1, 2, 3], "b": 5}) 1432s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _ test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_conn] _ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s func = 'read_sql', dtype_backend = 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1432s def test_read_sql_dtype(conn, request, func, dtype_backend): 1432s # GH#50797 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s ______ test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_engine] _______ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1432s request = > 1432s func = 'read_sql', dtype_backend = 'numpy_nullable' 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1432s def test_read_sql_dtype(conn, request, func, dtype_backend): 1432s # GH#50797 1432s conn = request.getfixturevalue(conn) 1432s table = "test" 1432s df = DataFrame({"a": [1, 2, 3], "b": 5}) 1432s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _______ test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_conn] ________ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s func = 'read_sql', dtype_backend = 'numpy_nullable' 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1432s def test_read_sql_dtype(conn, request, func, dtype_backend): 1432s # GH#50797 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s ___ test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_engine] ____ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s func = 'read_sql', dtype_backend = 'numpy_nullable' 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1432s def test_read_sql_dtype(conn, request, func, dtype_backend): 1432s # GH#50797 1432s conn = request.getfixturevalue(conn) 1432s table = "test" 1432s df = DataFrame({"a": [1, 2, 3], "b": 5}) 1432s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s ____ test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_conn] _____ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s func = 'read_sql', dtype_backend = 'numpy_nullable' 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1432s def test_read_sql_dtype(conn, request, func, dtype_backend): 1432s # GH#50797 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _ test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_engine] _ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1432s request = > 1432s func = 'read_sql_query', dtype_backend = 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1432s def test_read_sql_dtype(conn, request, func, dtype_backend): 1432s # GH#50797 1432s conn = request.getfixturevalue(conn) 1432s table = "test" 1432s df = DataFrame({"a": [1, 2, 3], "b": 5}) 1432s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _ test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_conn] _ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s func = 'read_sql_query', dtype_backend = 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1432s def test_read_sql_dtype(conn, request, func, dtype_backend): 1432s # GH#50797 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _ test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_engine] _ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s func = 'read_sql_query', dtype_backend = 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1432s def test_read_sql_dtype(conn, request, func, dtype_backend): 1432s # GH#50797 1432s conn = request.getfixturevalue(conn) 1432s table = "test" 1432s df = DataFrame({"a": [1, 2, 3], "b": 5}) 1432s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _ test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_conn] _ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s func = 'read_sql_query', dtype_backend = 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1432s def test_read_sql_dtype(conn, request, func, dtype_backend): 1432s # GH#50797 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s ___ test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_engine] ____ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1432s request = > 1432s func = 'read_sql_query', dtype_backend = 'numpy_nullable' 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1432s def test_read_sql_dtype(conn, request, func, dtype_backend): 1432s # GH#50797 1432s conn = request.getfixturevalue(conn) 1432s table = "test" 1432s df = DataFrame({"a": [1, 2, 3], "b": 5}) 1432s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s ____ test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_conn] _____ 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s > sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3.13/socket.py:864: in create_connection 1432s raise exceptions[0] 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s address = ('localhost', 3306), timeout = 10, source_address = None 1432s 1432s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1432s source_address=None, *, all_errors=False): 1432s """Connect to *address* and return the socket object. 1432s 1432s Convenience function. Connect to *address* (a 2-tuple ``(host, 1432s port)``) and return the socket object. Passing the optional 1432s *timeout* parameter will set the timeout on the socket instance 1432s before attempting to connect. If no *timeout* is supplied, the 1432s global default timeout setting returned by :func:`getdefaulttimeout` 1432s is used. If *source_address* is set it must be a tuple of (host, port) 1432s for the socket to bind as a source address before making the connection. 1432s A host of '' or port 0 tells the OS to use the default. When a connection 1432s cannot be created, raises the last error if *all_errors* is False, 1432s and an ExceptionGroup of all errors if *all_errors* is True. 1432s """ 1432s 1432s host, port = address 1432s exceptions = [] 1432s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1432s af, socktype, proto, canonname, sa = res 1432s sock = None 1432s try: 1432s sock = socket(af, socktype, proto) 1432s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1432s sock.settimeout(timeout) 1432s if source_address: 1432s sock.bind(source_address) 1432s > sock.connect(sa) 1432s E ConnectionRefusedError: [Errno 111] Connection refused 1432s 1432s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1432s 1432s During handling of the above exception, another exception occurred: 1432s 1432s self = 1432s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1432s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'mysql_pymysql_conn' 1432s request = > 1432s func = 'read_sql_query', dtype_backend = 'numpy_nullable' 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1432s def test_read_sql_dtype(conn, request, func, dtype_backend): 1432s # GH#50797 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1432s with mysql_pymysql_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1432s self.connect() 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s self = , sock = None 1432s 1432s def connect(self, sock=None): 1432s self._closed = False 1432s try: 1432s if sock is None: 1432s if self.unix_socket: 1432s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1432s sock.settimeout(self.connect_timeout) 1432s sock.connect(self.unix_socket) 1432s self.host_info = "Localhost via UNIX socket" 1432s self._secure = True 1432s if DEBUG: 1432s print("connected using unix_socket") 1432s else: 1432s kwargs = {} 1432s if self.bind_address is not None: 1432s kwargs["source_address"] = (self.bind_address, 0) 1432s while True: 1432s try: 1432s sock = socket.create_connection( 1432s (self.host, self.port), self.connect_timeout, **kwargs 1432s ) 1432s break 1432s except OSError as e: 1432s if e.errno == errno.EINTR: 1432s continue 1432s raise 1432s self.host_info = "socket %s:%d" % (self.host, self.port) 1432s if DEBUG: 1432s print("connected using socket") 1432s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1432s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1432s sock.settimeout(None) 1432s 1432s self._sock = sock 1432s self._rfile = sock.makefile("rb") 1432s self._next_seq_id = 0 1432s 1432s self._get_server_information() 1432s self._request_authentication() 1432s 1432s # Send "SET NAMES" query on init for: 1432s # - Ensure charaset (and collation) is set to the server. 1432s # - collation_id in handshake packet may be ignored. 1432s # - If collation is not specified, we don't know what is server's 1432s # default collation for the charset. For example, default collation 1432s # of utf8mb4 is: 1432s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1432s # - MySQL 8.0: utf8mb4_0900_ai_ci 1432s # 1432s # Reference: 1432s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1432s # - https://github.com/wagtail/wagtail/issues/9477 1432s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1432s self.set_character_set(self.charset, self.collation) 1432s 1432s if self.sql_mode is not None: 1432s c = self.cursor() 1432s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1432s c.close() 1432s 1432s if self.init_command is not None: 1432s c = self.cursor() 1432s c.execute(self.init_command) 1432s c.close() 1432s 1432s if self.autocommit_mode is not None: 1432s self.autocommit(self.autocommit_mode) 1432s except BaseException as e: 1432s self._rfile = None 1432s if sock is not None: 1432s try: 1432s sock.close() 1432s except: # noqa 1432s pass 1432s 1432s if isinstance(e, (OSError, IOError)): 1432s exc = err.OperationalError( 1432s CR.CR_CONN_HOST_ERROR, 1432s f"Can't connect to MySQL server on {self.host!r} ({e})", 1432s ) 1432s # Keep original exception and traceback to investigate error. 1432s exc.original_exception = e 1432s exc.traceback = traceback.format_exc() 1432s if DEBUG: 1432s print(exc.traceback) 1432s > raise exc 1432s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1432s _ test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_engine] _ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s request = > 1432s func = 'read_sql_query', dtype_backend = 'numpy_nullable' 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1432s def test_read_sql_dtype(conn, request, func, dtype_backend): 1432s # GH#50797 1432s conn = request.getfixturevalue(conn) 1432s table = "test" 1432s df = DataFrame({"a": [1, 2, 3], "b": 5}) 1432s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1432s return func(*args, **kwargs) 1432s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1432s return sql.to_sql( 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1432s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1432s return SQLDatabase(con, schema, need_transaction) 1432s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1432s con = self.exit_stack.enter_context(con.connect()) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _ test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_conn] __ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s conn = 'postgresql_psycopg2_conn' 1432s request = > 1432s func = 'read_sql_query', dtype_backend = 'numpy_nullable' 1432s 1432s @pytest.mark.parametrize("conn", all_connectable) 1432s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1432s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1432s def test_read_sql_dtype(conn, request, func, dtype_backend): 1432s # GH#50797 1432s > conn = request.getfixturevalue(conn) 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1432s fixturedef = self._get_active_fixturedef(argname) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1432s fixturedef.execute(request=subrequest) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1432s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1432s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1432s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1432s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1432s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1432s return (yield) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1432s result = call_fixture_func(fixturefunc, request, kwargs) 1432s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1432s fixture_result = next(generator) 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1432s with postgresql_psycopg2_engine.connect() as conn: 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _________________________ test_psycopg2_schema_support _________________________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s postgresql_psycopg2_engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s 1432s @pytest.mark.db 1432s def test_psycopg2_schema_support(postgresql_psycopg2_engine): 1432s conn = postgresql_psycopg2_engine 1432s 1432s # only test this for postgresql (schema's not supported in 1432s # mysql/sqlite) 1432s df = DataFrame({"col1": [1, 2], "col2": [0.1, 0.2], "col3": ["a", "n"]}) 1432s 1432s # create a schema 1432s > with conn.connect() as con: 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3905: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s _________________________ test_self_join_date_columns __________________________ 1432s self = 1432s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s connection = None, _has_events = None, _allow_revalidate = True 1432s _allow_autobegin = True 1432s 1432s def __init__( 1432s self, 1432s engine: Engine, 1432s connection: Optional[PoolProxiedConnection] = None, 1432s _has_events: Optional[bool] = None, 1432s _allow_revalidate: bool = True, 1432s _allow_autobegin: bool = True, 1432s ): 1432s """Construct a new Connection.""" 1432s self.engine = engine 1432s self.dialect = dialect = engine.dialect 1432s 1432s if connection is None: 1432s try: 1432s > self._dbapi_connection = engine.raw_connection() 1432s 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s 1432s The above exception was the direct cause of the following exception: 1432s 1432s postgresql_psycopg2_engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1432s 1432s @pytest.mark.db 1432s def test_self_join_date_columns(postgresql_psycopg2_engine): 1432s # GH 44421 1432s conn = postgresql_psycopg2_engine 1432s from sqlalchemy.sql import text 1432s 1432s create_table = text( 1432s """ 1432s CREATE TABLE person 1432s ( 1432s id serial constraint person_pkey primary key, 1432s created_dt timestamp with time zone 1432s ); 1432s 1432s INSERT INTO person 1432s VALUES (1, '2021-01-01T00:00:00Z'); 1432s """ 1432s ) 1432s > with conn.connect() as con: 1432s 1432s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3989: 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1432s return self._connection_cls(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1432s Connection._handle_dbapi_exception_noconnection( 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1432s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1432s self._dbapi_connection = engine.raw_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1432s return self.pool.connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1432s return _ConnectionFairy._checkout(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1432s fairy = _ConnectionRecord.checkout(pool) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1432s rec = pool._do_get() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1432s return self._create_connection() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1432s return _ConnectionRecord(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1432s self.__connect() 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1432s with util.safe_reraise(): 1432s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1432s raise exc_value.with_traceback(exc_tb) 1432s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1432s self.dbapi_connection = connection = pool._invoke_creator(self) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1432s return dialect.connect(*cargs, **cparams) 1432s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1432s return self.loaded_dbapi.connect(*cargs, **cparams) 1432s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1432s 1432s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1432s connection_factory = None, cursor_factory = None 1432s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1432s kwasync = {} 1432s 1432s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1432s """ 1432s Create a new database connection. 1432s 1432s The connection parameters can be specified as a string: 1432s 1432s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1432s 1432s or using a set of keyword arguments: 1432s 1432s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1432s 1432s Or as a mix of both. The basic connection parameters are: 1432s 1432s - *dbname*: the database name 1432s - *database*: the database name (only as keyword argument) 1432s - *user*: user name used to authenticate 1432s - *password*: password used to authenticate 1432s - *host*: database host address (defaults to UNIX socket if not provided) 1432s - *port*: connection port number (defaults to 5432 if not provided) 1432s 1432s Using the *connection_factory* parameter a different class or connections 1432s factory can be specified. It should be a callable object taking a dsn 1432s argument. 1432s 1432s Using the *cursor_factory* parameter, a new default cursor factory will be 1432s used by cursor(). 1432s 1432s Using *async*=True an asynchronous connection will be created. *async_* is 1432s a valid alias (for Python versions where ``async`` is a keyword). 1432s 1432s Any other keyword parameter will be passed to the underlying client 1432s library: the list of supported parameters depends on the library version. 1432s 1432s """ 1432s kwasync = {} 1432s if 'async' in kwargs: 1432s kwasync['async'] = kwargs.pop('async') 1432s if 'async_' in kwargs: 1432s kwasync['async_'] = kwargs.pop('async_') 1432s 1432s dsn = _ext.make_dsn(dsn, **kwargs) 1432s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1432s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1432s E Is the server running on that host and accepting TCP/IP connections? 1432s E 1432s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1432s 1432s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1432s =============================== warnings summary =============================== 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:895 1432s /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 1432s pytest.param("mysql_pymysql_engine", marks=pytest.mark.db), 1432s 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:896 1432s /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 1432s pytest.param("mysql_pymysql_conn", marks=pytest.mark.db), 1432s 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:900 1432s /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 1432s pytest.param("mysql_pymysql_engine_iris", marks=pytest.mark.db), 1432s 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:901 1432s /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 1432s pytest.param("mysql_pymysql_conn_iris", marks=pytest.mark.db), 1432s 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:905 1432s /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 1432s pytest.param("mysql_pymysql_engine_types", marks=pytest.mark.db), 1432s 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:906 1432s /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 1432s pytest.param("mysql_pymysql_conn_types", marks=pytest.mark.db), 1432s 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:910 1432s /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 1432s pytest.param("postgresql_psycopg2_engine", marks=pytest.mark.db), 1432s 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:911 1432s /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 1432s pytest.param("postgresql_psycopg2_conn", marks=pytest.mark.db), 1432s 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:915 1432s /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 1432s pytest.param("postgresql_psycopg2_engine_iris", marks=pytest.mark.db), 1432s 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:916 1432s /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 1432s pytest.param("postgresql_psycopg2_conn_iris", marks=pytest.mark.db), 1432s 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:920 1432s /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 1432s pytest.param("postgresql_psycopg2_engine_types", marks=pytest.mark.db), 1432s 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:921 1432s /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 1432s pytest.param("postgresql_psycopg2_conn_types", marks=pytest.mark.db), 1432s 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:954 1432s /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 1432s pytest.param("postgresql_adbc_conn", marks=pytest.mark.db), 1432s 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:958 1432s /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 1432s pytest.param("postgresql_adbc_iris", marks=pytest.mark.db), 1432s 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:959 1432s /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 1432s pytest.param("sqlite_adbc_iris", marks=pytest.mark.db), 1432s 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:963 1432s /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 1432s pytest.param("postgresql_adbc_types", marks=pytest.mark.db), 1432s 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:964 1432s /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 1432s pytest.param("sqlite_adbc_types", marks=pytest.mark.db), 1432s 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3896 1432s /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 1432s @pytest.mark.db 1432s 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3971 1432s /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 1432s @pytest.mark.db 1432s 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_datetime.py:1143 1432s /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 1432s @pytest.mark.skip_ubsan 1432s 1432s io/test_sql.py: 1535 warnings 1432s tools/test_to_datetime.py: 978 warnings 1432s /usr/lib/python3/dist-packages/py/_process/forkedfunc.py:45: DeprecationWarning: This process (pid=15774) is multi-threaded, use of fork() may lead to deadlocks in the child. 1432s pid = os.fork() 1432s 1432s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1432s /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-8u7npyxt' 1432s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1432s 1432s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:429 1432s /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-4d1xgkri' 1432s config.cache.set("cache/lastfailed", self.lastfailed) 1432s 1432s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1432s /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-twjfo38k' 1432s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1432s 1432s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1432s =========================== short test summary info ============================ 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[mysql_pymysql_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[mysql_pymysql_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[postgresql_psycopg2_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[postgresql_psycopg2_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[mysql_pymysql_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[mysql_pymysql_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[postgresql_psycopg2_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[postgresql_psycopg2_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[mysql_pymysql_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[mysql_pymysql_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[postgresql_psycopg2_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[postgresql_psycopg2_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[mysql_pymysql_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[mysql_pymysql_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[postgresql_psycopg2_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[postgresql_psycopg2_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[mysql_pymysql_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[mysql_pymysql_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[postgresql_psycopg2_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[postgresql_psycopg2_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[mysql_pymysql_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[mysql_pymysql_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[postgresql_psycopg2_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[postgresql_psycopg2_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[mysql_pymysql_engine_types] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[mysql_pymysql_conn_types] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[postgresql_psycopg2_engine_types] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[postgresql_psycopg2_conn_types] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_procedure[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_procedure[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[2-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[2-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_on_public_schema[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_on_public_schema[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_update[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_update[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_view_postgres[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_view_postgres[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[mysql_pymysql_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[mysql_pymysql_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[postgresql_psycopg2_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[postgresql_psycopg2_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[mysql_pymysql_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[mysql_pymysql_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[postgresql_psycopg2_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[postgresql_psycopg2_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[mysql_pymysql_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[mysql_pymysql_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[postgresql_psycopg2_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[postgresql_psycopg2_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[mysql_pymysql_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[mysql_pymysql_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[mysql_pymysql_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[mysql_pymysql_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[postgresql_psycopg2_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[postgresql_psycopg2_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[mysql_pymysql_engine_types] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[mysql_pymysql_conn_types] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[postgresql_psycopg2_engine_types] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[postgresql_psycopg2_conn_types] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[mysql_pymysql_engine_types] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[mysql_pymysql_conn_types] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[postgresql_psycopg2_engine_types] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[postgresql_psycopg2_conn_types] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_conn] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label_multiindex[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label_multiindex[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[mysql_pymysql_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[mysql_pymysql_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[postgresql_psycopg2_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[postgresql_psycopg2_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[mysql_pymysql_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[mysql_pymysql_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[postgresql_psycopg2_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[postgresql_psycopg2_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[mysql_pymysql_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[mysql_pymysql_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[postgresql_psycopg2_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[postgresql_psycopg2_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[mysql_pymysql_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[mysql_pymysql_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[postgresql_psycopg2_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[postgresql_psycopg2_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[mysql_pymysql_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[mysql_pymysql_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[postgresql_psycopg2_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[postgresql_psycopg2_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[mysql_pymysql_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[mysql_pymysql_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[postgresql_psycopg2_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[postgresql_psycopg2_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[mysql_pymysql_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[mysql_pymysql_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[postgresql_psycopg2_engine_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[postgresql_psycopg2_conn_iris] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_default_type_conversion[postgresql_psycopg2_engine_types] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_default_type_conversion[postgresql_psycopg2_conn_types] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[mysql_pymysql_engine_types] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[mysql_pymysql_conn_types] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[postgresql_psycopg2_engine_types] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[postgresql_psycopg2_conn_types] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[None-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[None-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_table[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_table[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[mysql_pymysql_engine_types] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[mysql_pymysql_conn_types] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[postgresql_psycopg2_engine_types] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[postgresql_psycopg2_conn_types] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[postgresql_psycopg2_conn] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_conn] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_conn] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_engine] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_conn] 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_psycopg2_schema_support 1432s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_self_join_date_columns 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[mysql_pymysql_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[mysql_pymysql_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[postgresql_psycopg2_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[postgresql_psycopg2_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[mysql_pymysql_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[mysql_pymysql_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[postgresql_psycopg2_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[postgresql_psycopg2_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[mysql_pymysql_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[mysql_pymysql_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[postgresql_psycopg2_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[postgresql_psycopg2_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[mysql_pymysql_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[mysql_pymysql_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[postgresql_psycopg2_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[postgresql_psycopg2_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[mysql_pymysql_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[mysql_pymysql_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[postgresql_psycopg2_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[postgresql_psycopg2_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[mysql_pymysql_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[mysql_pymysql_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[postgresql_psycopg2_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[postgresql_psycopg2_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[mysql_pymysql_engine_types] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[mysql_pymysql_conn_types] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[postgresql_psycopg2_engine_types] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[postgresql_psycopg2_conn_types] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_procedure[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_procedure[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[2-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[2-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_on_public_schema[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_on_public_schema[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_update[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_update[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_view_postgres[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_view_postgres[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[mysql_pymysql_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[mysql_pymysql_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[postgresql_psycopg2_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[postgresql_psycopg2_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[mysql_pymysql_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[mysql_pymysql_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[postgresql_psycopg2_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[postgresql_psycopg2_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[mysql_pymysql_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[mysql_pymysql_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[postgresql_psycopg2_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[postgresql_psycopg2_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[mysql_pymysql_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[mysql_pymysql_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[mysql_pymysql_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[mysql_pymysql_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[postgresql_psycopg2_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[postgresql_psycopg2_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[mysql_pymysql_engine_types] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[mysql_pymysql_conn_types] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[postgresql_psycopg2_engine_types] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[postgresql_psycopg2_conn_types] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[mysql_pymysql_engine_types] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[mysql_pymysql_conn_types] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[postgresql_psycopg2_engine_types] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[postgresql_psycopg2_conn_types] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_conn] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label_multiindex[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label_multiindex[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[mysql_pymysql_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[mysql_pymysql_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[postgresql_psycopg2_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[postgresql_psycopg2_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[mysql_pymysql_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[mysql_pymysql_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[postgresql_psycopg2_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[postgresql_psycopg2_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[mysql_pymysql_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[mysql_pymysql_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[postgresql_psycopg2_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[postgresql_psycopg2_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[mysql_pymysql_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[mysql_pymysql_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[postgresql_psycopg2_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[postgresql_psycopg2_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[mysql_pymysql_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[mysql_pymysql_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[postgresql_psycopg2_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[postgresql_psycopg2_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[mysql_pymysql_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[mysql_pymysql_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[postgresql_psycopg2_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[postgresql_psycopg2_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[mysql_pymysql_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[mysql_pymysql_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[postgresql_psycopg2_engine_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[postgresql_psycopg2_conn_iris] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_default_type_conversion[postgresql_psycopg2_engine_types] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_default_type_conversion[postgresql_psycopg2_conn_types] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[mysql_pymysql_engine_types] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[mysql_pymysql_conn_types] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[postgresql_psycopg2_engine_types] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[postgresql_psycopg2_conn_types] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[None-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[None-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_table[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_table[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[mysql_pymysql_engine_types] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[mysql_pymysql_conn_types] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[postgresql_psycopg2_engine_types] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[postgresql_psycopg2_conn_types] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[postgresql_psycopg2_conn] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_conn] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_conn] 1432s 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] 1432s 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] 1432s 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] 1432s 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] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_engine] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_conn] 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_psycopg2_schema_support 1432s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_self_join_date_columns 1432s = 588 failed, 1481 passed, 400 skipped, 54 xfailed, 2536 warnings, 592 errors in 467.88s (0:07:47) = 1432s autopkgtest [17:47:32]: test ignoredtests: -----------------------] 1434s autopkgtest [17:47:34]: test ignoredtests: - - - - - - - - - - results - - - - - - - - - - 1434s ignoredtests PASS 1434s autopkgtest [17:47:34]: @@@@@@@@@@@@@@@@@@@@ summary 1434s command1 PASS 1434s unittests3 PASS 1434s ignoredtests PASS 1451s nova [W] Using flock in prodstack6-s390x 1451s Creating nova instance adt-questing-s390x-pandas-20250506-172340-juju-7f2275-prod-proposed-migration-environment-2-c8a79876-2c77-4977-a1c6-4944993fc9f9 from image adt/ubuntu-questing-s390x-server-20250505.img (UUID 235ae1f0-b461-4906-9827-678093d41c66)... 1451s nova [W] Timed out waiting for 6ef7d20d-393e-47cd-ba5e-063d98452a92 to get deleted.